Reputation: 1758
I keep on getting error 502 bad gateway in my flask application that I'm trying to deploy to AWS. At the root of my folder, I have a file application.py, which contains:
import os
from flask import Flask, Blueprint
from flask_restful import Api
from api.user_endpoints import (
bp_api, #This is a blueprint
SignUp
)
application = Flask(__name__)
api = Api(bp_api)
api.add_resource(SignUp, '/v1.0/signup/')
application.register_blueprint(bp_api, url_prefix='/api')
@application.route("/")
def hello():
return "<h1 style='color:blue'>Hello There!</h1>"
if __name__ == '__main__':
application.run()
This is one of my logs:
----------------------------------------
/var/log/web.stdout.log
----------------------------------------
Nov 24 23:10:47 ip-172-31-11-56 web: File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
Nov 24 23:10:47 ip-172-31-11-56 web: File "<frozen importlib._bootstrap>", line 983, in _find_and_load
Nov 24 23:10:47 ip-172-31-11-56 web: File "<frozen importlib._bootstrap>", line 965, in _find_and_load_unlocked
Nov 24 23:10:47 ip-172-31-11-56 web: ModuleNotFoundError: No module named 'application'
When running "eb config" from the command line, I have:
WSGIPath: application:application.py
I tried
WSGIPath: application.py
and
WSGIPath: application
but I always get the same result. How to solve this situation, or at least how to troubleshoot it better?
Edit: Here is the content of my requirements.txt:
wheel
flask
flask_login
flask_sqlalchemy
flask_bcrypt
flask_babel
flask_restful
flask_wtf
flask_api
pandas
joblib
boto3
sklearn
requests
email_validator
authlib
pyarmor
mysql-connector
uwsgi
supervisor
Upvotes: 2
Views: 596
Reputation: 238597
I tried to replicate your issue using 64bit Amazon Linux 2 v3.1.0 running Python 3.7
, but it all works for me. To test I had to remove the api.user_endpoints
parts from your code as I don't have them, but no other changes were required.
Also there was no need to modify WSGIPath
. So whatever is happening for you, its something not shown in your question.
Upvotes: 1