I am trying to host a Flask app that implements a REST API using Flask-RESTful on Elastic Beanstalk through the eb cli
. I have successfully deployed my application and I am not getting any error messages on my events log. I can successfully ssh into the instances and run the script to prepopulate my database and everything. But whenever I try to access any routes I keep getting a 404 error.
I initially assumed that it was because it wasn't finding my WSGIPath, so I changed the file name to application.py
and updated the EBS software configuration to point to that file. I have also updated all instances of app
to application
in the codebase based on AWS documentation. Still nothing. Does anyone have any idea what could be wrong?
This is my application.py
:
from flask import Flask
from config import Config
CONFIG = Config()
# AWS Elastic Beanstalk expects an `application` variable.
application = Flask(__name__)
if __name__ == "__main__":
# Importing these here to avoid issue with circular imports
from endpoints.v1.exports import exports_api
from endpoints.v1.imports import imports_api
application.register_blueprint(exports_api, url_prefix="/api/v1")
application.register_blueprint(imports_api, url_prefix="/api/v1")
application.run(debug=CONFIG.DEBUG)
Here is where the application.py
file lies in the folder structure:
- project root
- ...
- application.py
- ...