cherrypy

Handling HTTP/1.1 Upgrade requests in CherryPy

泄露秘密 提交于 2019-12-12 13:10:44
问题 I'm using CherryPy for a web server, but would like it to handle HTTP/1.1 Upgrade requests. Thus, when a client sends: OPTIONS * HTTP/1.1 Upgrade: NEW_PROTOCOL/1.0 Connection: Upgrade I'd like the server to hand the connection off to some NEW_PROTOCOL handler after responding with the necessary HTTP/1.1 101 Switching Protocols... , as specified in RFC 2817. I'm pretty new to CherryPy, and couldn't find anything in the documentation on how to handle specific client requests such as the above.

HTTPS to HTTP using CherryPy

…衆ロ難τιáo~ 提交于 2019-12-12 12:14:31
问题 Is it possible for CherryPy to redirect HTTP to HTTPS. Lets for example say the code below is http://example.com if someone visits via https://example.com I want them to be redirected to the plain HTTP URL (301 redirect maybe?) how do I accomplish this? #!/usr/bin/env python from pprint import pformat from cherrypy import wsgiserver def app(environ, start_response): status = '200 OK' response_headers = [('Content-type', 'text/plain')] start_response(status, response_headers) return [pformat

pyinstaller: 2 instances of my cherrypy app exe get executed

主宰稳场 提交于 2019-12-12 10:46:09
问题 I have a cherrypy app that I've made an exe with pyinstaller. now when I run the exe it loads itself twice into memory. Watching the taskmanager shows the first instance load into about 1k, then a second later a second instance of hte exe loads into about 3k ram. If I close the bigger one both processes die. If I close hte smaller one only that one dies. Loading the exe with subprocess, if I try to proc.kill(), it only kills the small one leaving the other running in memory. Is this a

CherryPy, Threads, and Member Variables; potential issues?

馋奶兔 提交于 2019-12-12 09:18:18
问题 Let's say I have the following simple class: import cherrypy import os class test: test_member = 0; def __init__(self): return def index(self): self.test_member = self.test_member + 1 return str(self.test_member) index.exposed = True conf = os.path.join(os.path.dirname(__file__), 'config.ini') if __name__ == '__main__': # CherryPy always starts with app.root when trying to map request URIs # to objects, so we need to mount a request handler root. A request # to '/' will be mapped to

How run cherrypy app without screen logging?

∥☆過路亽.° 提交于 2019-12-12 04:34:57
问题 Hi I looking for some configuration or flag that allows me to silence the requested pages. When I run python cherrypy_app.py and I join to the 127.0.0.1:8080 in the console where I start the cherrypy app show me 127.0.0.1 - - [09/Oct/2014:19:10:35] "GET / HTTP/1.1" 200 1512 "" "Mozilla/5.0 ..." 127.0.0.1 - - [09/Oct/2014:19:10:35] "GET /static/css/style.css HTTP/1.1" 200 88 "http://127.0.0.1:8080/" "Mozilla/5.0 ..." 127.0.0.1 - - [09/Oct/2014:19:10:36] "GET /favicon.ico HTTP/1.1" 200 1406 ""

Can a standalone web application built with cherrypy be compiled?

梦想与她 提交于 2019-12-12 04:25:22
问题 I want to build a web application that stands completely by itself, apache not required. Is cherrypy a good solution, and can this be compiled with something like py2exe? 回答1: Python is a scripting language and is not usually compiled. What you are talking about is packaging your scripts into an exe (via p2exe), bundled with the relative modules and an interpreter. This is possible with many scripts, including CherryPy, as p2exe basically sticks all your scripts together in one place, then

Doing auto redirect using CherryPy

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-12 03:54:44
问题 I've just discovered CherryPy. I am going through the tutorial, so far so good. While doing it I wanted to create a "BUSY DOING WORK" splash screen, essentially I have a python function that for example updates an sqlite table with 10000 records. What I want to do is get CherryPy to display a busy.html page while the database is being updated, when the database operation completes I want to redirect the user back to the main.html page. So far I have only come across dev update_db(self): #Code

Peewee says “cannot commit - no transaction is active”

痴心易碎 提交于 2019-12-12 02:45:43
问题 My CherryPy app does some cleaning every hour with the following code: def every_hour(): two_hours_ago = time.time() - 2 * 60 * 60 DbChoice.delete().where(DbChoice.time_stamp < two_hours_ago).execute() monitor_every_hour = Monitor(cherrypy.engine, every_hour, frequency=60 * 60) monitor_every_hour.start() Sometimes it crashes with he following message: Traceback (most recent call last): File "C:\Python34\lib\site-packages\peewee.py", line 2364, in execute_sql self.commit() File "C:\Python34

How do I properly use psycopg2 with cherrypy?

安稳与你 提交于 2019-12-12 02:18:16
问题 I wrote a CherryPy webapp the other day. Some data is queried from PostgreSQL and I use psycopg2 for that. While everything worked alright in my local testing, it sometimes falls apart in real conditions (much more pageloads). Unfortunately, I do not have the exact traceback messages right now but they were about not being able to connect or a connection being closed already if I recall correctly. I will add them as soon as I can. Psycopg / Postgres : Connections hang out randomly seems to

Cherrypy + sqlite3 + Peewee crashes when two processes execute the same code at the same time

为君一笑 提交于 2019-12-11 18:57:56
问题 Navigating to the page test?x=a defined below it works. Navigating to test?x=a and then quickly navigating to test?x=b , both the cycles will keep running for a few seconds, but one of them will eventually crash with the error peewee.OperationalError: cannot start a transaction within a transaction . This is obviously not a real world test, it is a way to reproduce the real world problems that I am having once in a while. In the real world application I see errors similar to this one when