Python 在web上部署一个简单的flask应用程序
我已经按照“”中的描述设置了一个示例testapp,以运行一个基本的webapp 下面是代码片段和结构: “在web服务器上” 我的httpd.conf存储在/home//webapps/testapp/apache2/conf下,如下所示:Python 在web上部署一个简单的flask应用程序,python,flask,mod-wsgi,webfaction,Python,Flask,Mod Wsgi,Webfaction,我已经按照“”中的描述设置了一个示例testapp,以运行一个基本的webapp 下面是代码片段和结构: “在web服务器上” 我的httpd.conf存储在/home//webapps/testapp/apache2/conf下,如下所示: import sys testapp = "/home/<user>/webapps/testapp/htdocs" if not testapp in sys.path: sys.path.insert(0, testapp) fro
import sys
testapp = "/home/<user>/webapps/testapp/htdocs"
if not testapp in sys.path:
sys.path.insert(0, testapp)
from testapp import app as application
from flask import Flask
app = Flask(__name__)
@app.route('/')
def hello_world():
return 'Hello World!'
if __name__ == '__main__':
app.run()
ServerRoot "/home/<user>/webapps/testapp/apache2"
LoadModule dir_module modules/mod_dir.so
LoadModule env_module modules/mod_env.so
LoadModule log_config_module modules/mod_log_config.so
LoadModule mime_module modules/mod_mime.so
LoadModule rewrite_module modules/mod_rewrite.so
LoadModule setenvif_module modules/mod_setenvif.so
LoadModule wsgi_module modules/mod_wsgi.so
LogFormat "%{X-Forwarded-For}i %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User- Agent}i\"" combined
CustomLog /home/<user>/logs/user/access_testapp.log combined
DirectoryIndex index.py
DocumentRoot /home/<user>/webapps/testapp/htdocs
ErrorLog /home/<user>/logs/user/error_testapp.log
KeepAlive Off
Listen 24329
MaxSpareThreads 3
MinSpareThreads 1
ServerLimit 1
SetEnvIf X-Forwarded-SSL on HTTPS=1
ThreadsPerChild 5
WSGIDaemonProcess testapp processes=5 python-path=/home/<user>/webapps/testapp /lib/python3.1 threads=1
WSGIProcessGroup testapp
WSGIRestrictEmbedded On
WSGILazyInitialization On
WSGIPythonPath /home/<user>/webapps/testapp/htdocs
WSGIScriptAlias / /home/<user>/webapps/testapp/htdocs/index.py
<Directory /home/<user>/webapps/testapp/htdocs>
AddHandler wsgi-script .py
ReWriteEngine on
RewriteBase /
WSGIScriptReloading On
</Directory>
我已经检查了user's下的error_testapp.log,如下所示:
[Mon Feb 04 07:45:05 2013] [notice] caught SIGTERM, shutting down
[Mon Feb 04 07:45:10 2013] [notice] Apache/2.2.17 (Unix) mod_wsgi/3.4 Python/3.2.3 configured -- resuming normal operations
[Mon Feb 04 07:57:14 2013] [notice] caught SIGTERM, shutting down
[Mon Feb 04 07:57:19 2013] [notice] Apache/2.2.17 (Unix) mod_wsgi/3.4 Python/3.2.3 configured -- resuming normal operations
在尝试从http://.webpartial.com/testapp启动应用程序时/
我收到“站点未配置”消息
有人能告诉我这里可能出了什么问题吗?这是我第一次使用Flask和webfaction。提前感谢您的时间。如果您需要更多详细信息,请告诉我。-您需要切换回Python 2.7.3(或者查看CherryPy或Pyramid,因为这两个框架都支持Python 3)
testapp
Name testapp
Label mod_wsgi 3.4/Python 3.2
Machine
Web377
Description
mod_wsgi 3.4/Python 3.2
Port 24329
[Mon Feb 04 07:45:05 2013] [notice] caught SIGTERM, shutting down
[Mon Feb 04 07:45:10 2013] [notice] Apache/2.2.17 (Unix) mod_wsgi/3.4 Python/3.2.3 configured -- resuming normal operations
[Mon Feb 04 07:57:14 2013] [notice] caught SIGTERM, shutting down
[Mon Feb 04 07:57:19 2013] [notice] Apache/2.2.17 (Unix) mod_wsgi/3.4 Python/3.2.3 configured -- resuming normal operations