Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
219 views
in Technique[技术] by (71.8m points)

python - Error while deploying flask app on apache

I have a file manage.py,

import os
from app import create_app
app = create_app(os.getenv('FLASK_CONFIG') or 'default')
if __name__ == '__main__':
    app.run()

manage.py is working fine when tested in debug mode. However, I'm not able to host it on apache.

my wsgi file: start.wsgi

from manage import app as application
import sys
sys.stdout = sys.stderr

virtual host:

<VirtualHost *:80>
   ServerName domain.com
   WSGIDaemonProcess manage user=user group=user threads=5
   WSGIScriptAlias / /var/www/apioflifeapp/app/start.wsgi
   <Directory /var/www/apioflifeapp/app>
        Require all granted
        Options all
        AllowOverride all
        Allow from all
   </Directory>
</VirtualHost>

error in error log

 [Sat Feb 21 10:55:47.329450 2015] [:error] [pid 25422] [client 197.226.128.204:56062]   File "/var/www/apioflifeapp/app/start.wsgi", line 1, in <module>
    [Sat Feb 21 10:55:47.329601 2015] [:error] [pid 25422] [client 197.226.128.204:56062]     from manage import app as application
    [Sat Feb 21 10:55:47.329624 2015] [:error] [pid 25422] [client 197.226.128.204:56062] ImportError: No module named manage

i'm not understanding why i'm getting the import error

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You need to import the app name from your actual application, not manage. Assuming it's apioflifeapp, you would import the following in start.wsgi instead:

from apioflifeapp import app as application

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...