无法在Webfaction上部署简单的Flask应用程序 [英] Can't deploy a simple Flask application on Webfaction

查看:143
本文介绍了无法在Webfaction上部署简单的Flask应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直试图让Flask在我的webfaction服务器上工作几个小时,没有任何结果。

我按照 http:// flask.pocoo.org/snippets/65/

我有我的index.py文件存储在htdocs下。

  import sys 
yourappname =/ home /< myusername> / webapps / myapp / htdocs
如果不是sys.path中的yourappname:
sys.path.insert(0,yourappname)
$ b $ from yourappname import app as application

然后我把它添加到我的httpd.conf文件中:

  WSGIPythonPath / home / yourusername / webapps / yourapp / htdocs / 
#如果你没有指定下面的指令,app *将会工作,但是你会在
中看到index.py URLs
WSGIScriptAlias / /home/yourusername/webapps/yourapp/htdocs/index.py

<目录/ home / yourusername / webapps / yourapp / htdocs />
AddHandler wsgi-script .py
RewriteEngine on
RewriteBase /
WSGIScriptReloading On
< / Directory>

然后我将myapp.py放在index.py旁边的htdocs目录中:



pre $ from flask import Flask
app = Flask(__ name__)

@ app.route('/' )
def hello_world():
return'Hello World!'

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

我的域名指向了webfaction中的项目。默认的index.py在我覆盖之前正在工作,如说明中所述的那样。但是,我只得到服务器500.我很抱歉,但我是一个完整的noob当涉及到Linux和管理服务器。我甚至无法访问我的用户下的错误日志,因为它说我没有权限。

我认为这与我在linux服务器上安装烧瓶有关,我通过简单的安装来安装它,它说它安装了所有的依赖关系,并没有给出任何错误。

解决方案

几个建议:
$ b $ ol <

  • 你不应该在你的index.py中有yourappname吗?另外,我假设你在`WSGIPythonPath / home / yourusername / webapps / yourapp / htdocs

  • 中做了适当的替换你试过了吗?通过发行〜/ webapps /< app_name> / apache2 / bin / restart


  • 重新启动Apache服务器

    I have been trying to get Flask to work on my webfaction server for hours with no results.

    I followed the instructions at http://flask.pocoo.org/snippets/65/

    I have my index.py file stored under htdocs.

    import sys
    yourappname = "/home/<myusername>/webapps/myapp/htdocs"
    if not yourappname in sys.path:
        sys.path.insert(0, yourappname)
    
    from yourappname import app as application 
    

    Then I have added this to my httpd.conf file:

    WSGIPythonPath /home/yourusername/webapps/yourapp/htdocs/
    #If you do not specify the following directive the app *will* work but you will
    #see index.py in the path of all URLs
    WSGIScriptAlias / /home/yourusername/webapps/yourapp/htdocs/index.py
    
    <Directory /home/yourusername/webapps/yourapp/htdocs/>
       AddHandler wsgi-script .py
       RewriteEngine on
       RewriteBase /
       WSGIScriptReloading On
    </Directory>
    

    then i have myapp.py in the same htdocs directory next to index.py:

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

    I have my domain pointed to my project in webfaction. The default index.py was working prior to me overwriting with the new one as stated in the instructions. However, I only get the server 500. I apologize but I am a complete noob when it comes to linux and managing servers. I cannot even access my error log under users because it says I do not have permission.

    I think that it has something to do with my installation of flask on the linux server, i installed it through easy install it says it installed all of the dependencies and did not give any errors.

    解决方案

    A couple of suggestions:

    1. Shouldn't you have myapp everywhere you have yourappname in your index.py?
    2. Also, I am assuming that you have made the appropriate substitutions in `WSGIPythonPath /home/yourusername/webapps/yourapp/htdocs
    3. Have you tried restarting the apache server by issuing a ~/webapps/<app_name>/apache2/bin/restart

    这篇关于无法在Webfaction上部署简单的Flask应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆