How deploy Flask application on Webfaction?

前端 未结 2 1300
隐瞒了意图╮
隐瞒了意图╮ 2021-01-31 06:38

Anybody know how to deploy a simple Flask application on Webfaction? I know Webfaction support mod_wsgi and I read the guide on the Flask site but still I can\'t make my app wor

2条回答
  •  自闭症患者
    2021-01-31 06:58

    I got it working with the following procedure:

    • create and app named 'myapp' of type mod_wsgi 3.3/Python 2.7. Webfaction will create the following folders:

      myapp
           |- apache2
           |- htdocs
      
    • Webfaction will also automatically create a simple script index.py in your htdocs directory. Check if the sample script work visiting the root of your newly created application (to do thin on Webfaction you need to "mount" the app on a website). If it's all OK modify the script deleting the content and adding:

      from myapp import app as application
      
    • In apache2/conf/httpd.conf add the follwing lines:

      WSGIPythonPath /home/username/webapps/myapp/htdocs/
      #If you do not specify the next directive the app *will* work but you will
      #see index.py in the path of all subdir
      WSGIScriptAlias / /home/username/webapps/myapp/htdocs/index.py
      
      
      
          AddHandler wsgi-script .py
          RewriteEngine on
          RewriteBase /
          WSGIScriptReloading On
      
      
    • Restart apache2

提交回复
热议问题