我想使用pythonanywhere公开部署我的flask应用程序。我完全遵循了所有步骤。尝试使用virtualenv和不使用virtualenv来实现它,但没有效果。
我可以使简单的烧瓶页面“ Hello to flask app”正常工作,但是我的代码无法正常工作。
路径为/ home / anwaraliafshan / bella,文件为afshan.py
这是我的WSGI.py,我尝试用bella和afshan替换flask,但是没有任何效果。 虽然在python3上成功安装了imutil,但也在error.log中获得了导入imutil错误。 请帮助我找到原因。预先感谢
# This file contains the WSGI configuration required to serve up your
# web application at http://<your-username>.pythonanywhere.com/
# It works by setting the variable 'application' to a WSGI handler of some
# description.
#
# The below has been auto-generated for your Flask project
import sys
# add your project directory to the sys.path
project_home = '/home/anwaraliafshan/bella/'
if project_home not in sys.path:
sys.path = [project_home] + sys.path
# import flask app but need to call it "application" for WSGI to work
from flask import app as application # noqa
答案 0 :(得分:3)
引自他们的website:
import sys
path = '/home/yourusername/mysite'
if path not in sys.path:
sys.path.insert(0, path)
from flask_app import app as application