bottle

Getting peewee to work on elastic beanstalk

梦想的初衷 提交于 2019-12-02 10:48:09
问题 I'm trying to install the peewee package on an elastic beanstalk instance to control a bottle application. I think the problem is with the MySQL-python dependency, but peewee doesn't load either. My requirements file looks like this: bottle==0.11.6 peewee==2.1.1 MySQL-python I also tried MySQL-python as MySQL-python==1.2.4b4 . For a number of reasons which I believe are summed up here, this doesn't work; peewee isn't installed and I get this error message in the log: 2013-05-18 06:57:08,407

Getting peewee to work on elastic beanstalk

点点圈 提交于 2019-12-02 04:24:32
I'm trying to install the peewee package on an elastic beanstalk instance to control a bottle application. I think the problem is with the MySQL-python dependency, but peewee doesn't load either. My requirements file looks like this: bottle==0.11.6 peewee==2.1.1 MySQL-python I also tried MySQL-python as MySQL-python==1.2.4b4 . For a number of reasons which I believe are summed up here , this doesn't work; peewee isn't installed and I get this error message in the log: 2013-05-18 06:57:08,407 [INFO] (15947 MainThread) [directoryHooksExecutor.py-29] [root directoryHooksExecutor info] Script

Python bottle - How to upload media files without DOSing the server

筅森魡賤 提交于 2019-12-02 03:05:50
I was using the answer from this question and saw the comment: raw = data.file.read() # This is dangerous for big files How do I upload the file without doing this? My code so far is: @bottle.route('/uploadLO', method='POST') def upload_lo(): upload_dir = get_upload_dir_path() files = bottle.request.files print files, type(files) if(files is not None): file = files.file print file.filename, type(file) target_path = get_next_file_name(os.path.join(upload_dir, file.filename)) print target_path shutil.copy2(file.read(), target_path) #does not work. Tried it as a replacement for php's move

Streaming Connection Using Python Bottle, Multiprocessing, and gevent

最后都变了- 提交于 2019-12-01 18:38:53
I have a Bottle application that uses subprocesses to do most of the work for requests. For routes that return a single response, I do something like what's below. @route('/index') def index(): worker = getWorker() return worker.doStuff() One of my routes needs to be a data stream. I can't figure out a smart way to have the worker return a response stream. The example below is similar to what I want to do, only without a worker. @route('/stream') def stream(): yield 'START' sleep(3) yield 'MIDDLE' sleep(5) yield 'END' I'd like to be able to do something like below. Since I can't yield/return a

Access the response object in a bottlepy after_request hook

不羁岁月 提交于 2019-12-01 18:01:48
I have the following web app: import bottle app = bottle.Bottle() @app.route('/ping') def ping(): print 'pong' return 'pong' @app.hook('after_request') def after(): print 'foo' print bottle.response.body if __name__ == "__main__": app.run(host='0.0.0.0', port='9999', server='cherrypy') Is there a way to access the response body before sending the response back? If I start the app and I query /ping , I can see in the console that the ping() and the after() function run in the right sequence $ python bottle_after_request.py Bottle v0.11.6 server starting up (using CherryPyServer())... Listening

Binary file download

只愿长相守 提交于 2019-12-01 17:49:04
I'm building a server using python and bottle. How can I handle a request for a binary file? I have read that I should use flask. There is a way for doing that without using flask? Yes, you should use static_file function: from bottle import static_file @route('/download/<filename:path>') def download(filename): return static_file(filename, root='/path/to/static/files', download=filename) 来源: https://stackoverflow.com/questions/13725417/binary-file-download

Combine two python decorators into one

旧时模样 提交于 2019-12-01 06:33:23
Here are two decorators I'd like to combine as they are pretty similar, the difference is how a not authenticated user is handled. I'd prefer to have one single decorator that I can call with an argument. # Authentication decorator for routes # Will redirect to the login page if not authenticated def requireAuthentication(fn): def decorator(**kwargs): # Is user logged on? if "user" in request.session: return fn(**kwargs) # No, redirect to login page else: redirect('/login?url={0}{1}'.format(request.path, ("?" + request.query_string if request.query_string else ''))) return decorator #

Combine two python decorators into one

泪湿孤枕 提交于 2019-12-01 05:23:40
问题 Here are two decorators I'd like to combine as they are pretty similar, the difference is how a not authenticated user is handled. I'd prefer to have one single decorator that I can call with an argument. # Authentication decorator for routes # Will redirect to the login page if not authenticated def requireAuthentication(fn): def decorator(**kwargs): # Is user logged on? if "user" in request.session: return fn(**kwargs) # No, redirect to login page else: redirect('/login?url={0}{1}'.format

ImportError: No module named bottle

我的未来我决定 提交于 2019-12-01 03:40:23
$ sudo pip install bottle Downloading/unpacking bottle Downloading bottle-0.10.7.tar.gz (55Kb): 55Kb downloaded Running setup.py egg_info for package bottle Installing collected packages: bottle Found existing installation: bottle 0.10.7 Uninstalling bottle: Successfully uninstalled bottle Running setup.py install for bottle changing mode of build/scripts-2.6/bottle.py from 640 to 755 changing mode of /usr/local/bin/bottle.py to 755 Successfully installed bottle >>> help('modules') blahblah bottle blahblah $ ls /usr/local/lib/python2.6/dist-packages/ bottle-0.10.7.egg-info bottle.py bottle.pyc

ImportError: No module named bottle

↘锁芯ラ 提交于 2019-11-30 23:37:09
问题 $ sudo pip install bottle Downloading/unpacking bottle Downloading bottle-0.10.7.tar.gz (55Kb): 55Kb downloaded Running setup.py egg_info for package bottle Installing collected packages: bottle Found existing installation: bottle 0.10.7 Uninstalling bottle: Successfully uninstalled bottle Running setup.py install for bottle changing mode of build/scripts-2.6/bottle.py from 640 to 755 changing mode of /usr/local/bin/bottle.py to 755 Successfully installed bottle >>> help('modules') blahblah