Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

successfully deployed flask app but getting a 404 when accessing the page

I was able to deploy a sample flask app to AWS using the instructions from this document http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create_deploy_Python_flask.html

the status from "eb status" is Green

Retrieving status of environment "helloflask-env" shows

=================================================================

URL : helloflask-env-m3mncmbmpv.elasticbeanstalk.com

Status : Ready

Health : Green

Environment Name: helloflask-env

Environment ID: e-mdp3jwtq9p

Solution Stack: 64bit Amazon Linux running Python

Version Label: git-05103eab3255781f58fdbaf1df8078aa4b008d4b-1369170804114

Date Created: 2013-05-21 10:45:25

Date Updated: 2013-05-21 14:14:33

=================================================================

However, when trying to access the url helloflask-env-m3mncmbmpv.elasticbeanstalk.com, I get a 404 error with the following message:

Not Found The requested URL / was not found on this server. Apache/2.2.22 (Amazon) Server at helloflask-env-m3mncmbmpv.elasticbeanstalk.com Port 80

Has anyone seen something similar to this? thanks!

like image 518
Michael Avatar asked Dec 16 '22 10:12

Michael


2 Answers

I also had a same issue. I'm using flask 0.10 and now it works fine.

from example

from flask import Flask
app = Flask(__name__)

@app.route("/")     
def hello():         
    return "Hello World!"

if __name__ == "__main__":         
    app.run() 

to

from flask import Flask
application = Flask(__name__)  # Change assignment here

@application.route("/")        # Change your route statements
def hello():         
    return "Hello World!"

if __name__ == "__main__":         
    application.run()          # Change all other references to 'app'

this link will help you.

like image 51
Woongbi Kim Avatar answered Jan 17 '23 17:01

Woongbi Kim


I've figured out the error in my case. It's due to a WSGIPath error.

The error occurred because I have the application.py in the app/ folder. But because I ran the git .init command in its parent folder, EB errors out because it cannot find application.py file.

In short, the solution is to run "eb init" in the same location where you have your application.py file!

like image 45
Michael Avatar answered Jan 17 '23 18:01

Michael