I built a website using the flask application factory method but I am having trouble deploying it since I keep getting 'ModuleNotFoundError' in my error logs. My directory structure is pretty simple:
- mysite/
- Website/ (the python package)
- main.py
- init.py
- views.py
- auth.py
my main.py file:
from website import create_app
app = create_app()
if __name__ == '__main__':
app.run()
my init.py file:
from flask import Flask
def create_app():
app = Flask(__name__)
app.config['SECRERT_KEY'] = '1b2l9d5ti8bffhf'
from .auth import auth
from .views import views
app.register_blueprint(views, url_prefix='/')
app.register_blueprint(auth, url_prefix='/')
return app
my wsgi.py file:
import sys
# add your project directory to the sys.path
project_home = '/home/Mp08100/mysite/website'
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 website import create_app
application = create_app() # noqa
I don't know what I am doing wrong but my error logs keep saying:
Error running WSGI application
ModuleNotFoundError: No module named 'website'
File "/var/www/mp08100_pythonanywhere_com_wsgi.py", line 16, in <module>
from main import app as application # noqa File "/home/Mp08100/mysite/main.py", line 1, in <module> from website import my_site