Deploying Python Flask app on web using pythonanywhere

筅森魡賤 提交于 2020-03-21 06:40:29

问题


I want to deploy my flask app publicly using pythonanywhere. I have followed all steps exactly. Tried implementing it with virtualenv and without virtualenv but none works.

I can get the simple flask page 'Hello to flask app" working but my code is not working.

Path is /home/anwaraliafshan/bella and file is afshan.py

This is my WSGI.py and I tried replacing flask with bella and afshan but nothing worked. Also getting import imutil error in error.log though install imutil successfully on python3 Please help me finding the cause. Thanks in advance

# 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

回答1:


As quoted from their 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


来源:https://stackoverflow.com/questions/53867776/deploying-python-flask-app-on-web-using-pythonanywhere

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!