bottle

Bottle web framework - How to stop?

狂风中的少年 提交于 2019-11-27 14:32:53
问题 When starting a bottle webserver without a thread or a subprocess, there's no problem. To exit the bottle app -> CTRL + c . In a thread, how can I programmatically stop the bottle web server ? I didn't find a stop() method or something like that in the documentation. Is there a reason ? 回答1: For the default (WSGIRef) server, this is what I do (actually it is a cleaner approach of Vikram Pudi's suggestion): from bottle import Bottle, ServerAdapter class MyWSGIRefServer(ServerAdapter): server =

How to load a javascript or css file into a BottlePy template?

我的梦境 提交于 2019-11-27 05:26:24
问题 I am trying to return a html template with BottlePy. And this works fine. But if I insert a javascript file like this in my tpl-file: <script type="text/javascript" src="js/main.js" charset="utf-8"></script> I get an 404 error. (Failed to load resource: the server responded with a status of 404 (Not Found)) Does anyone know how to fix this problem? Here is my script file: from bottle import route, run, view @route('/') @view('index') def index(): return dict() run(host='localhost', port=8080)

Bottle framework and OOP, using method instead of function

大城市里の小女人 提交于 2019-11-27 05:08:20
问题 I've done some coding with Bottle. It's really simple and fits my needs. However, I got stick when I tried to wrap the application into a class : import bottle app = bottle class App(): def __init__(self,param): self.param = param # Doesn't work @app.route("/1") def index1(self): return("I'm 1 | self.param = %s" % self.param) # Doesn't work @app.route("/2") def index2(self): return("I'm 2") # Works fine @app.route("/3") def index3(): return("I'm 3") Is it possible to use methods instead of

Bottle Py: Enabling CORS for jQuery AJAX requests

耗尽温柔 提交于 2019-11-27 01:01:53
I'm working on a RESTful API of a web service on the Bottle Web Framework and want to access the resources with jQuery AJAX calls. Using a REST client, the resource interfaces work as intended and properly handle GET, POST, ... requests. But when sending a jQuery AJAX POST request, the resulting OPTIONS preflight request is simply denied as '405: Method not allowed'. I tried to enable CORS on the Bottle server - as described here: http://bottlepy.org/docs/dev/recipes.html#using-the-hooks-plugin But the after_request hook is never called for the OPTIONS request. Here is an excerpt of my server:

ImportError: No module named 'bottle' - PyCharm

戏子无情 提交于 2019-11-26 22:06:44
I installed bottle on python3.4 with pip install. In terminal, when I do: $ python3.4 >>>import bottle # shows no import error >>> but when I do it in PyCharm, it says "import bottle ImportError: No module named 'bottle'" in your PyCharm project: press Ctrl + Alt + s to open the settings on the left column, select Project Interpreter on the top right there is a list of python binaries found on your system, pick the right one eventually click the + button to install additional python modules validate In some cases no "No module ..." can appear even on local files. In such cases you just need to

NGINX + uWSGI Connection Reset by Peer

烂漫一生 提交于 2019-11-26 16:37:22
问题 I'm trying to host Bottle Application on NGINX using uWSGI. Here's my nginx.conf location /myapp/ { include uwsgi_params; uwsgi_param X-Real-IP $remote_addr; uwsgi_param Host $http_host; uwsgi_param UWSGI_SCRIPT myapp; uwsgi_pass 127.0.0.1:8080; } I'm running uwsgi as this uwsgi --enable-threads --socket :8080 --plugin python -- wsgi-file ./myApp/myapp.py I'm using POST Request. For that using dev Http Client. Which goes infinite when I send the request http://localhost/myapp uWSGI server

Bottle Py: Enabling CORS for jQuery AJAX requests

烂漫一生 提交于 2019-11-26 12:26:10
问题 I\'m working on a RESTful API of a web service on the Bottle Web Framework and want to access the resources with jQuery AJAX calls. Using a REST client, the resource interfaces work as intended and properly handle GET, POST, ... requests. But when sending a jQuery AJAX POST request, the resulting OPTIONS preflight request is simply denied as \'405: Method not allowed\'. I tried to enable CORS on the Bottle server - as described here: http://bottlepy.org/docs/dev/recipes.html#using-the-hooks

ImportError: No module named &#39;bottle&#39; - PyCharm

China☆狼群 提交于 2019-11-26 07:33:08
问题 I installed bottle on python3.4 with pip install. In terminal, when I do: $ python3.4 >>>import bottle # shows no import error >>> but when I do it in PyCharm, it says \"import bottle ImportError: No module named \'bottle\'\" 回答1: in your PyCharm project: press Ctrl + Alt + s to open the settings on the left column, select Project Interpreter on the top right there is a list of python binaries found on your system, pick the right one eventually click the + button to install additional python