cherrypy

Python Cherrypy Access Log Rotation

对着背影说爱祢 提交于 2019-12-07 08:12:38
问题 If I want the access log for Cherrypy to only get to a fixed size, how would I go about using rotating log files? I've already tried http://www.cherrypy.org/wiki/Logging, which seems out of date, or has information missing. 回答1: Look at http://docs.python.org/library/logging.html. You probably want to configure a RotatingFileHandler http://docs.python.org/library/logging.html#rotatingfilehandler 回答2: I've already tried http://www.cherrypy.org/wiki/Logging, which seems out of date, or has

CherryPy3 and IIS 6.0

青春壹個敷衍的年華 提交于 2019-12-07 07:23:34
问题 I have a small Python web application using the Cherrypy framework. I am by no means an expert in web servers. I got Cherrypy working with Apache using mod_python on our Ubuntu server. This time, however, I have to use Windows 2003 and IIS 6.0 to host my site. The site runs perfectly as a stand alone server - I am just so lost when it comes to getting IIS running. I have spent the past day Googling and blindly trying any and everything to get this running. I have all the various tools

How to catch all exceptions with CherryPy?

社会主义新天地 提交于 2019-12-07 06:22:44
问题 I use CherryPy to run a very simple web server. It is intended to process the GET parameters and, if they are correct, do something with them. import cherrypy class MainServer(object): def index(self, **params): # do things with correct parameters if 'a' in params: print params['a'] index.exposed = True cherrypy.quickstart(MainServer()) For example, http://127.0.0.1:8080/abcde: 404 Not Found The path '/abcde' was not found. Traceback (most recent call last): File "C:\Python27\lib\site

cherrypy and wxpython

人走茶凉 提交于 2019-12-07 01:30:20
问题 I'm trying to make a cherrypy application with a wxpython ui. The problem is both libraries use closed loop event handlers. Is there a way for this to work? If I have the wx ui start cherrypy is that going to lock up the ui? 回答1: See my answer at CherryPy interferes with Twisted shutting down on Windows In short, CherryPy handles the main loop by default, but it definitely doesn't need to. Stop using quickstart and call engine.start without engine.block, and CP will run in its own threads and

Streaming POST a large file to CherryPy by Python client

大城市里の小女人 提交于 2019-12-06 14:26:06
问题 I'm want to POST a large file from a python client to cherrypy. I'm using the requests library. This is my client code: def upload(fileName=None): url = 'http://localhost:8080/upload' files = {'myFile': ( fileName, open(fileName, 'rb') )} r = requests.post(url, files=files) #with open(fileName,'rb') as payload: #headers = {'content-type': 'multipart/form-data'} #r = requests.post('http://127.0.0.1:8080', data=payload,verify=False,headers=headers) if __name__ == '__main__': upload(sys.argv[1])

Using Flask with CherryPy to serve static files

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-06 13:04:43
First time using a web framework, hope to get advice on the correct approach. My aim is to have a server which can return static files based on a url passed in. I use Flask as my web framework and I intent to use CherryPy as my web server. The web describes many ways of setting up Flask with CherryPy and I am not sure if I am doing it correctly. Resources I have been using: http://rhodesmill.org/brandon/2011/wsgi-under-cherrypy/ Flask, CherryPy and static content http://fgimian.github.io/blog/2012/12/08/setting-up-a-rock-solid-python-development-web-server/ http://flask.pocoo.org/docs

Large file downloads in cherrypy

岁酱吖の 提交于 2019-12-06 10:07:40
问题 I'm hosting a file access type website using Cherrypy, through uwsgi and nginx on a Raspberry Pi. One thing I've noticed is that if the file is rather large (let's say, about a gigabyte), uwsgi says it was killed by signal 9. This was remedied by putting a cherrypy.config.update({'tools.sessions.timeout': 1000000}) but this doesn't really solve the problem, as much as it is a bad hacky workaround that doesn't really work. It mainly just causes another problem by making the timeout very large.

Profiling CherryPy

断了今生、忘了曾经 提交于 2019-12-06 06:36:53
问题 I've been trying to start profiling my CherryPy webserver, but the documentation is lacking in detail in how this should be set up. I understand that I should be able to use cherrypy.lib.profiler as middleware to mount my initial server. Right now, I have code like the following: server_app = ServerClass() cherrypy.tree.mount(server_app, '/', '/path/to/config/file.cfg') cherrypy.engine.start() cherrypy.engine.block() I want to mount the profiling middleware, and it seems that something like

Getting Data back from Python with Cherrypy and jQuery/AJAX

拥有回忆 提交于 2019-12-06 06:14:51
Unfortunately i dont get ajax to work properly with cherrypy. Here is my python code: from mako.template import Template from mako.lookup import TemplateLookup import cherrypy import os import json CURDIR = os.getcwd() cherrypy.config.update({ "tools.staticdir.root" : CURDIR, "tools.staticdir.dir" : "static", "tools.staticdir.on" : True }) # Loopuoobjekt für die Templates tmplLookup = TemplateLookup(directories=['templates']) # Liefert das Gerenderte Template zurück def serve_template(templatename, **tmpl_vars): template = tmplLookup.get_template(templatename) return template.render(**tmpl

Psycopg / Postgres : Connections hang out randomly

断了今生、忘了曾经 提交于 2019-12-06 05:34:52
I'm using psycopg2 for the cherrypy app I'm currently working on and cli & phpgadmin to handle some operations manually. Here's the python code : #One connection per thread cherrypy.thread_data.pgconn = psycopg2.connect("...") ... #Later, an object is created by a thread : class dbobj(object): def __init__(self): self.connection=cherrypy.thread_data.pgconn self.curs=self.connection.cursor(cursor_factory=psycopg2.extras.DictCursor) ... #Then, try: blabla self.curs.execute(...) self.connection.commit() except: self.connection.rollback() lalala ... #Finally, the destructor is called : def __del__