Reputation: 15
I see this issue posted alot...but no solutions thus far have worked for me (sorry about the repost).
PROBLEM I'm trying to run flask on my windows10 machine, and am unable to load a simple hello.py without a 404 error.
DEBUGGER The debugger is working for syntax errors (I can see the lines from hello.py file in my browser if I break the syntax in the file...but I'm getting no help on the 404 if the py file doesn't contain errors. The terminal also detects changes to the file it's supposed to load on the screen.
(I take it this means that the venv is set up properly, and the issue lies in the network handlers on windows..)
Things I've done I've tried.
Code for hello.py
'''
from flask import Flask
from werkzeug.debug import DebuggedApplication
app = Flask(__name__)
app.route('/')
def index():
return '<h1>hello world</h1>'
if __name__ =='__main__':
app.run(host='localhost', port=5000, debug=True)
'''
File Tree
_pycache_
Include
Lib
Scripts
hello.py
pip-selfcheck.json
pyvenv.cfg
Upvotes: 0
Views: 1016
Reputation: 855
You did not wrote the decorator for the index Function the right way.
This is a fixed Version who should work:
@app.route('/')
def index():
return '<h1>hello world</h1>'
The @
symbol is needed to tell python that this function was decorated with the route.
Upvotes: 1