Im studying AWS EB and my already done Flask app doesnt work, only 502 error. The app works on my pc but not on aws.
I tried to change the variable 'app' to 'application' and the file name from 'main.py' to 'application.py' as this link suggests but still couldnt find my error.
Folder structure:
- -venv
- --website
- ---static
- ---templates
- ---init.py
- ---auth.py
- ---models.py
- ---views.py
- --application.py
- --requirements.txt
Inside init.py:
from flask import Flask
from flask_sqlalchemy import SQLAlchemy
from flask_login import LoginManager
db = SQLAlchemy()
DB_NAME = 'database.db'
def create_app():
application = Flask(__name__)
application.config["SQLALCHEMY_DATABASE_URI"] = f"sqlite:///{DB_NAME}"
db.init_app(application)
login_manager = LoginManager()
login_manager.init_app(application)
login_manager.login_view = 'auth.login'
from .views import views
from .auth import auth
from .models import Note,User
application.register_blueprint(views,url_prefix='/')
application.register_blueprint(auth,url_prefix='/')
with application.app_context():
db.create_all()
print('Database created')
@login_manager.user_loader
def load_user(id):
return User.query.get(int(id))
return application
Inside application.py:
from website import create_app
application = create_app()
if __name__=='__main__':
application.run()
I think its the folder management that Im doing wrong, I tried to eliminate the init and add it to application.py but couldnt make it right. If more infos needed I can give, this is just a personal note app Im trying to do.
source https://stackoverflow.com/questions/75152343/aws-elasticbeanstalk-flask-502-error-folder-management
Comments
Post a Comment