Afshan Anwarali
Afshan Anwarali

Reputation: 357

Deploying Python Flask app on web using pythonanywhere

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

Upvotes: 1

Views: 1769

Answers (1)

Julian Camilleri
Julian Camilleri

Reputation: 3095

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

Upvotes: 4

Related Questions