bottle

Nginx - Rewrite the request_uri before uwsgi_pass

落花浮王杯 提交于 2019-11-30 03:09:21
I have a Nginx vhost than is configured as such: ... location /one { include uwsgi_params; uwsgi_pass unix:///.../one.sock; } location /two { include uwsgi_params; uwsgi_pass unix:///.../two.sock } ... This is a simplified configuration of course When I request /one/something I would like my Python script to receive /something as request_uri . I'm using BottlePy but would like this to be handled by Nginx and not in my Python code. Can I do something like uwsgi_param REQUEST_URI replace($request_uri, '^/one', '') ? Edit Here is the request from my Python code: [pid: 30052|app: 0|req: 1/1] ()

How do you accept any URL in a Python Bottle server?

杀马特。学长 韩版系。学妹 提交于 2019-11-30 02:32:46
问题 Using a Bottle Sehttp://bottlepy.org/docs/dev/routing.html#wildcard-filters I'd like to accept any url, and then do something with the url. e.g. @bottle.route("/<url:path>") def index(url): return "Your url is " + url This is tricky because URLs have slashes in them, and Bottle splits by slashes. 回答1: Based on new Bottle (v0.10), use a re filter: @bottle.route("/<url:re:.+>") You can do that with old parameters too: @bottle.route("/:url#.+#") 回答2: I think you (OP) were on the right track to

Bottle Static files

落花浮王杯 提交于 2019-11-29 21:00:33
I have tried reading the docs for Bottle, however, I am still unsure about how static file serving works. I have an index.tpl file, and within it it has a css file attached to it, and it works. However, I was reading that Bottle does not automatically serve css files, which can't be true if the page loads correctly. I have, however, run into speed issues when requesting the page. Is that because I didn't use the return static_file(params go here) ? If someone could clear up how they work, and how they are used when loading the page, it would be great. Server code: from Bottle import route,run

How can I get Bottle to restart on file change?

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-29 16:05:55
问题 I'm really enjoying Bottle so far, but the fact that I have to CTRL+C out of the server and restart it every time I make a code change is a big hit on my productivity. I've thought about using Watchdog to keep track of files changing then restarting the server, but how can I do that when the bottle.run function is blocking. Running the server from an external script that watches for file changes seems like a lot of work to set up. I'd think this was a universal issue for Bottle, CherryPy and

Bottle-friendly WSGI authentication library/middleware [closed]

て烟熏妆下的殇ゞ 提交于 2019-11-29 08:54:59
问题 What I need is a lightweight authentication/ACL library or middleware which is preferably capable of openID (though this is not crucial), and would play nice with bottle framework (i.e, maybe not use exceptions as an internal flow-control mechanism). Any suggestions? EDIT: Any thoughts on barrel? 回答1: I suggest you look to repoze.who for authentication and repoze.what for authorization. Both of them are designed to be generic WSGI middleware and easily can work with any of WSGI frameworks.

Redirecting to a url with POST data using Python Bottle

时间秒杀一切 提交于 2019-11-29 08:01:23
Is there any way of adding POST data when redirecting to another page? I've built a service that will redirect the user back to whatever page is specified when the service is called. The problem is I can't put any GET parameters on the url due to complex and badly written rewrite rules etc. so I need to send a value with POST. Is there anyway of adding to Bottles redirect(return_url) or using some other lib in Python? You may build the response , instead of using the redirect(url) method of bottle from bottle import route, run, response @post('/wrong') def wrong(): response.status = 303

Python bottle module causes “Error: 413 Request Entity Too Large”

↘锁芯ラ 提交于 2019-11-29 06:07:56
问题 Using Python's module bottle , I'm getting HTTP 413 error when posting requests of body size > bottle 's internal MEMFILE_MAX constant. Minimal working example is shown below. Server part ( server.py ): from bottle import * @post('/test') def test(): return str(len(request.forms['foo'])); def main(): run(port=8008); if __name__ == '__main__': main(); Client part ( client.py ): import requests def main(): url = 'http://127.0.0.1:8008/test'; r = requests.post(url, data={ 'foo' : 100000 * 'a' })

Embed Plotly graph into a webpage with Bottle

笑着哭i 提交于 2019-11-29 03:05:08
问题 Hi i am using plotly to generate graphs using Python, Bottle. However, this returns me a url. Like: https://plot.ly/~abhishek.mitra.963/1 I want to paste the entire graph into my webpage instead of providing a link. Is this possible? My code is: import os from bottle import run, template, get, post, request from plotly import plotly py = plotly(username='user', key='key') @get('/plot') def form(): return '''<h2>Graph via Plot.ly</h2> <form method="POST" action="/plot"> Name: <input name=

How to get callback when key expires in REDIS

痴心易碎 提交于 2019-11-29 02:32:56
问题 I'm developing application using Bottle. In my registration form, I'm confirming email by mail with a unique key. I'm storing this key in REDIS with expiry of 4 days. If user does not confirm email within 4 days, key gets expired. for this, I want to permanently delete the user entry from my database(mongoDB). Ofcourse I dont require continous polling to my redis server to check whether key exists or not. Is there any way to get a callback from Redis?? OR is there any other efficient way? 回答1

running Apache + Bottle + Python

痞子三分冷 提交于 2019-11-29 02:03:14
I'm trying to run Bottle.py with Apache and mod_wsgi. I'm running it on windows, using a xampp. python v2.7 My Apache config in httpd: <VirtualHost *> ServerName example.com WSGIScriptAlias / C:\xampp\htdocs\GetXPathsProject\app.wsgi <Directory C:\xampp\htdocs\GetXPathsProject> Order deny,allow Allow from all </Directory> </VirtualHost> My app.wsgi code: import os os.chdir(os.path.dirname(__file__)) import bottle application = bottle.default_app() My hello.py: from bottle import route @route('/hello') def hello(): return "Hello World!" When I go to localhost/hello I get a 404 error. I don't