gpt4 book ai didi

python - 带有 uWSGI 的简单 Bottle 应用程序不工作(返回 404)

转载 作者:太空宇宙 更新时间:2023-11-03 15:13:24 24 4
gpt4 key购买 nike

我有一个使用 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

它在 127.0.0.1:8080 上运行时由 python bottle-hello.py 运行。但是当我尝试使用 uWSGI 运行它时:

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

访问 127.0.0.1:8000 会出现 404 not found 错误。

这是来自 uWSGI 输出的日志信息。最后一行显示它收到请求但没有返回任何内容......

*** 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)

最佳答案

修改后的代码如下:

import bottle

app = application = bottle.Bottle()

@app.route('/hello')
def hello():
return "hello world"

if __name__ == '__main__':
app.run(port=8080, debug=True)

关于python - 带有 uWSGI 的简单 Bottle 应用程序不工作(返回 404),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23899979/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com