【问题标题】:Deploying a simple flask app on web faction在网络派系上部署一个简单的烧瓶应用程序
【发布时间】:2013-02-04 09:04:56
【问题描述】:

我已经按照“Can't deploy a simple Flask application on Webfaction”中的描述设置了一个示例 testapp 来运行一个基本的 webapp。

下面是代码sn-p和结构:

“在网络派系服务器上”

/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://.webfactional.com/testapp/ 启动应用程序时

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

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

【问题讨论】:

    标签: python flask mod-wsgi webfaction


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-01-07
      • 1970-01-01
      • 2015-01-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-07-28
      相关资源
      最近更新 更多