Reputation: 33
I have a simple hello-world app built with Bottle:
from bottle import route, run
import bottle
app = bottle.Bottle()
@route('/hello')
def hello():
return "hello world"
if __name__ == '__main__':
run(port=8080, debug=True)
else:
application = app
It works on 127.0.0.1:8080 when ran by python bottle-hello.py
. But when I try to run it using uWSGI:
uwsgi --http :8000 --wsgi-file bottle-hello.py
Visiting 127.0.0.1:8000 gives a 404 not found error.
Here is the log info from uWSGI output. Last line show it receives the request but returns nothing ...
*** Starting uWSGI 2.0.4 (64bit) on [Tue May 27 15:12:52 2014] ***
compiled with version: 4.8.2 on 27 May 2014 14:05:00
os: Linux-3.13.0-27-generic #50-Ubuntu SMP Thu May 15 18:06:16 UTC 2014
nodename: ubuntu
machine: x86_64
clock source: unix
detected number of CPU cores: 1
current working directory: /apps/bottle-hello
detected binary path: /usr/local/bin/uwsgi
!!! no internal routing support, rebuild with pcre support !!!
*** WARNING: you are running uWSGI without its master process manager ***
your processes number limit is 7726
your memory page size is 4096 bytes
detected max file descriptor number: 1024
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
uWSGI http bound on :8000 fd 4
spawned uWSGI http 1 (pid: 8694)
uwsgi socket 0 bound to TCP address 127.0.0.1:48544 (port auto-assigned) fd 3
Python version: 2.7.6 (default, Mar 22 2014, 23:03:41) [GCC 4.8.2]
*** Python threads support is disabled. You can enable it with --enable-threads ***
Python main interpreter initialized at 0x25bb130
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 72752 bytes (71 KB) for 1 cores
*** Operational MODE: single process ***
WSGI app 0 (mountpoint='') ready in 0 seconds on interpreter 0x25bb130 pid: 8693 (default app)
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI worker 1 (and the only) (pid: 8693, cores: 1)
[pid: 8693|app: 0|req: 1/1] 127.0.0.1 () {36 vars in 632 bytes} [Tue May 27 15:13:01 2014] GET /hello => generated 730 bytes in 20 msecs (HTTP/1.1 404) 2 headers in 87 bytes (1 switches on core 0)
Upvotes: 3
Views: 1313
Reputation: 44112
Here comes corrected code:
import bottle
app = application = bottle.Bottle()
@app.route('/hello')
def hello():
return "hello world"
if __name__ == '__main__':
app.run(port=8080, debug=True)
Upvotes: 4