运行 Apache + Bottle + Python [英] running Apache + Bottle + Python
问题描述
我正在尝试使用 Apache 和 mod_wsgi 运行 Bottle.py.
I'm trying to run Bottle.py with Apache and mod_wsgi.
我在 Windows 上运行它,使用 xampp.蟒蛇 v2.7
I'm running it on windows, using a xampp. python v2.7
我在 httpd 中的 Apache 配置:
My Apache config in httpd:
<VirtualHost *>
ServerName example.com
WSGIScriptAlias / C:\xampp\htdocs\GetXPathsProject\app.wsgi
<Directory C:\xampp\htdocs\GetXPathsProject>
Order deny,allow
Allow from all
</Directory>
</VirtualHost>
我的 app.wsgi 代码:
My app.wsgi code:
import os
os.chdir(os.path.dirname(__file__))
import bottle
application = bottle.default_app()
我的hello.py:
My hello.py:
from bottle import route
@route('/hello')
def hello():
return "Hello World!"
当我转到 localhost/hello
时,我收到 404 错误.我在 Apache 日志文件中没有任何其他错误,可能缺少一些基本信息.
When I go to localhost/hello
I get a 404 error.
I don't have any other errors on the Apache log file, probably missing something basic.
推荐答案
wsgi 文件和 hello.py 文件之间没有连接点.
将 hello.py 中的内容放入 app.wsgi 并重新启动您的网络服务器.
那应该可以解决问题.
要使您的应用程序模块化,以便您可以将代码放入各种文件中,请查看 Bottle 的等效蓝图(由 Flask 框架使用)
There's no connecting point from your wsgi file to your hello.py file.
Put the content in your hello.py into the app.wsgi and restart your web server.
That should resolve the problem.
To make your application modular such that you can put the code into various files, check out Bottle's equivalent of Blueprints (used by Flask framework)
这篇关于运行 Apache + Bottle + Python的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!