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?
-
1can you give more informations? which step are you at? what does it say when it doesn't work/user1297061– user12970612014-06-20 20:10:46 +00:00Commented 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/…Roger Miller– Roger Miller2014-06-21 18:21:49 +00:00Commented 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.user1297061– user12970612014-06-27 07:48:43 +00:00Commented 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.Roger Miller– Roger Miller2014-06-28 15:04:59 +00:00Commented 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.user1297061– user12970612014-06-29 06:16:59 +00:00Commented Jun 29, 2014 at 6:16
Add a comment
|
1 Answer
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.