0

I am trying to learn how to build applications with Python Flask, and am having trouble with their tutorial at this address: http://flask.pocoo.org/docs/tutorial/. I followed all the instructions (folder structure, files, etc.) but when I run the application on the command line with python, the application does not run when I plug in the web address into my browser. I am very new to Python so any help would be appreciated. What could be going on?

5
  • 1
    can you give more informations? which step are you at? what does it say when it doesn't work/ Commented Jun 20, 2014 at 20:10
  • I went through all the steps and am just trying to fire up the application by entering in the command line my main application file: "$ python flaskr.py" The application begins to run and an IP address is returned, but when I go to the IP address, it gives me an error saying that the page does not exist, just like it did after the very first exercise when we started up the application. Here is a link to a Google Docs folder with all my files organized exactly as they are on my computer: drive.google.com/… Commented Jun 21, 2014 at 18:21
  • oh, and just a pointer, if you plan on learning flask and web dev in python, there is a great book flaskbook.com that explains things pretty well. I found online python web dev tutorials generally aren't very clear and detailed. Commented Jun 27, 2014 at 7:48
  • Thanks! I will definitely check that out! I've only been learning Python for the past six months, and most of it has been in data analysis, so web development has been tough. Commented Jun 28, 2014 at 15:04
  • I also came from a science background. yeah, web dev is a little different from science and math. udacity's python web dev course explains basics of web dev. udacity.com/course/cs253 looks like they are no longer free. but you can still try it for free for two weeks. Commented Jun 29, 2014 at 6:16

1 Answer 1

1

OK, I look through your code. It appears to be a simple error:

In flaskr.py, move these two lines to the end of the file.

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

Then it works. The reason is when you run python flaskr.py

it goes through the file and when it reaches those two lines it runs the server at which point route '/' is not registered. Therefore it gives a 404.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.