在Web派系上部署一个简单的烧瓶应用程序

时间:2013-02-04 09:04:56

标签: python flask mod-wsgi webfaction

我已按照“Can't deploy a simple Flask application on Webfaction”中的说明设置了一个示例testapp,以便运行基本的web应用程序。

以下是代码段和结构:

“在网络派系服务器上”

/home/<user>/webapps
ls
>> testapp ( <-- my testapp)
    cd testapp
    >> apache2 htdocs
    cd htdocs
    >> index.py testapp.py

我在htdocs下存储的index.py文件如下:

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

我在htdocs下存储的testapp.py文件如下:

from flask import Flask
app = Flask(__name__)
@app.route('/')            
def hello_world():
    return 'Hello World!'

if __name__ == '__main__':
    app.run()

我的httpd.conf存储在/ home // webapps / testapp / apache2 / conf下如下:

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>

我的域名指向了webfaction中的项目。在我使用新指令覆盖之前,默认的index.py正在使用,如说明中所述。

以下是我在网络派系控制面板部分中的应用程序的详细信息:

testapp
Name    testapp
Label   mod_wsgi 3.4/Python 3.2
Machine     
Web377
Description     
mod_wsgi 3.4/Python 3.2
Port    24329

我已经检查了用户下的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://&lt; user&gt; .webfactional.com / testapp /

启动应用时

我收到“网站未配置”消息。

有人可以说明这里可能出现的问题。这是我第一次使用Flask和webfaction.Thanks提前计算您的时间。如果您需要更多详细信息,请告诉我。

1 个答案:

答案 0 :(得分:0)

Flask does not support Python 3 currently - 你需要切换回Python 2.7.3(或者看看CherryPy或Pyramid,因为这两个框架都支持Python 3)。

相关问题