简体   繁体   English

uWSGI无效的简单瓶子应用程序(返回404)

[英]simple Bottle app with uWSGI not working (returns 404)

I have a simple hello-world app built with Bottle: 我有一个用Bottle构建的简单的hello-world应用程序:

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 . 当由python bottle-hello.py运行时,它适用于127.0.0.1:8080。 But when I try to run it using uWSGI: 但是当我尝试使用uWSGI运行它时:

uwsgi --http :8000 --wsgi-file bottle-hello.py

Visiting 127.0.0.1:8000 gives a 404 not found error. 访问127.0.0.1:8000会发现404未找到错误。

Here is the log info from uWSGI output. 这是uWSGI输出的日志信息。 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)

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)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM