bottle

bottle uwsgi nginx app returns 404

泄露秘密 提交于 2019-12-25 12:24:30
问题 OK, I've gone around and around on this and don't know what else to do: maybe someone can help. I'm trying to run a bottle app via uwsgi and nginx. It works fine if I run it with the bottle server, like this; python app.py and then point a browser to hostname:8080 but when run via nginx/uwsgi, and go to: hostname/apps/app1 I get the 404 error handler WITHIN THE APP, which reports a 404 error. So it's running the app: it just doesn't seem to match any of the route "decorators". Here's the app

bottle uwsgi nginx app returns 404

只愿长相守 提交于 2019-12-25 12:23:49
问题 OK, I've gone around and around on this and don't know what else to do: maybe someone can help. I'm trying to run a bottle app via uwsgi and nginx. It works fine if I run it with the bottle server, like this; python app.py and then point a browser to hostname:8080 but when run via nginx/uwsgi, and go to: hostname/apps/app1 I get the 404 error handler WITHIN THE APP, which reports a 404 error. So it's running the app: it just doesn't seem to match any of the route "decorators". Here's the app

json not working in javascript in bottle framework

♀尐吖头ヾ 提交于 2019-12-24 19:25:19
问题 I am now totally confused with the usage of data structures in bottle... Now I am using a Jquery tool ztree to build a tree in my web page. index.py: data = [{'name':'1'}, {'name':'2'}] return template('index', data) But, when I try to get data in my JavaScript code as {{data}} , and then pass it to ztree to build my tree, it shows nothing. On the other hand, if I pass [{'name':1'},{'name':2}] directly to ztree, a tree is built as expected. So what's the difference between the two? 回答1: You

How to link to an image in GridFS in an <img> tag?

早过忘川 提交于 2019-12-24 16:19:36
问题 We can think about how serving a list of images works in HTML. When we serve a page it includes tags that reference an image and then the browser makes a separate request to get each one. This works well with mongodb. We can just serve the page and insert tags like <img src="/profile_pics/userid"> and then our server just redirects that path to the GridFS file with {"profile_pic": userid} . Source : http://www.markus-gattol.name/ws/mongodb.html I have tried: HTML <li> <img src="/static/img

How to start Bottle as a daemon from another script?

青春壹個敷衍的年華 提交于 2019-12-24 06:01:47
问题 I would like to use BottlePy as a daemon started from another script and I have issues turning a standalone script ( webserver.py ) into a class. The standalone version of my webserver below works fine: import bottle @bottle.get('/hello') def hello(): return 'Hello World' @bottle.error(404) def error404(error): return 'error 404' bottle.run(host='localhost', port=8080) My intent is now to start it from the main script below as from webserver import WebServer from multiprocessing import

Serve a Bottle application from gunicorn on Heroku?

你离开我真会死。 提交于 2019-12-24 02:56:21
问题 Procfile web: python server.py server.py from os import environ from bottle import app, route, run, static_file @route('/') def root(): return "Hello world!" if __name__ == '__main__': run(server='gunicorn', host='0.0.0.0', port=int(environ.get("PORT", 5000))) requirements.txt gunicorn psycopg2 git+https://github.com/defnull/bottle#egg=bottle Relevant portion of logfile (after git push ) heroku[router]: at=error code=H14 desc="No web processes running" 回答1: First of all: Are you certain that

Is it possible to post an object from jquery to bottle.py?

我怕爱的太早我们不能终老 提交于 2019-12-24 01:55:14
问题 here is the jquery $.ajax({ type: "POST", url: "/posthere", dataType: "json", data: {myDict:{'1':'1', '2':'2'}}, success: function(data){ //do code } }); Here is the python @route("/posthere", method="POST") def postResource(myDict): #do code return "something" It looks like the the url formats on support int, float, path, and re... am I missing something? 回答1: There are only bytes on the wire. To send an object you need to serialize it using some data format e.g., json: $.ajax({ type: "POST"

problems deploying bottle application with google app engine

帅比萌擦擦* 提交于 2019-12-23 21:14:45
问题 newbie here--I've been trying to create a "Hello World" in bottle using google app engine. I got the "hello world" part to show up, but even on on index page, I get the following output: "Hello world!Status: 500" If I try to add new routes (like the '/page' route), and I navigate to the new route, I get "Server error: The website encountered an error while retrieving... It may be down for maintenance or configured incorrectly." After I navigate to the improperly configured page, if I try to

How to make Bottle print stacktrace when running through apache modwsgi?

风格不统一 提交于 2019-12-23 21:04:08
问题 When running Bottle as a standalone server it's very easy to do: from bottle import run, Bottle run(app=app, host=config.get('bottle_host', 'localhost'), port=config.get('bottle_port', '8080'), debug=config.get('debug', True), server=config.get('server_middleware', 'tornado')) The problem is that with wsgi I have to do this: app = Bottle() And Bottle constructor doesn't have any debug parameter. So what can I do to get the stacktrace? 回答1: import bottle bottle.debug(True) If you look at the

Emailing admin when a 500 error occurs

佐手、 提交于 2019-12-23 12:49:09
问题 How can I send an email to admin when a 500 error occurs, in python. The web framework I'm using is 'bottle'. 回答1: Just use the @error(code) decorator to define an error handling page, like so: from bottle import run, error, route @error(500) def handle_500_error(code): # add mail send code here return "Error message here" @route("/test_500") def cause_error(): raise Exception run() Just navigate to /test_500 to see it in action You can of course use a template for the error page just like