Forums

I keep getting this error and I don't know why and how do I fix it

2023-08-23 06:02:00,291: Error running WSGI application

2023-08-23 06:02:00,294: ImportError: cannot import name 'app' from 'flaskapp2023summer' (unknown location)

2023-08-23 06:02:00,294:   File "/var/www/cgmiao_pythonanywhere_com_wsgi.py", line 83, in <module>

2023-08-23 06:02:00,294:     from flaskapp2023summer import app as application  # noqa


2023-08-23 06:10:55,825: Error running WSGI application
2023-08-23 06:10:55,829: NameError: name 'app' is not defined
2023-08-23 06:10:55,829:   File "/var/www/cgmiao_pythonanywhere_com_wsgi.py", line 83, in <module>
2023-08-23 06:10:55,829:     from init.py import app as application  # noqa
2023-08-23 06:10:55,829: 
2023-08-23 06:10:55,829:   File "/home/cgmiao/flaskapp2023summer/init.py", line 3, in <module>
2023-08-23 06:10:55,830:     import backend.py
2023-08-23 06:10:55,830: 
2023-08-23 06:10:55,830:   File "/home/cgmiao/flaskapp2023summer/backend.py", line 33, in <module>
2023-08-23 06:10:55,830:     @app.route('/')

I have all of my files in a directory called flaskapp2023summer. enter link description here as shown in the attached image and in my wsgi.py I have my import as this: i

mport sys
#
## The "/home/cgmiao" below specifies your home
## directory -- the rest should be the directory you uploaded your Flask
## code to underneath the home directory.  So if you just ran
## "git clone git@github.com/myusername/myproject.git"
## ...or uploaded files to the directory "myproject", then you should
## specify "/home/cgmiao/myproject"
path = '/home/cgmiao/flaskapp2023summer'
if path not in sys.path:
    sys.path.append(path)
#
from backend import app as application  # noqa

and In my backend.py file I have

from flask import Flask, request, render_template, url_for, redirect, flash, session
from forms import RegistrationForm, LoginForm, SearchForm, DeleteAccountForm
import pymysql

# to run flask use "set FLASK_APP=backend.py"
# then "flask run" or "python backend.py" to have active changes for refresh (don't need to rerun code/flask)

app = Flask(__name__)

at the very top of my file.

what is your directories structure?