I'm trying to learn how to use Flask in Python
Run into situation I can't resolve.
What is wrong with the following code?
Python 3.11.5 (tags/v3.11.5:cce6ba9, Aug 24 2023, 14:38:34) [MSC v.1936 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license()" for more information.
= RESTART: C:\PYTHON\Workbench\Hello.py
Run into situation I can't resolve.
What is wrong with the following code?
from flask import Flask app = Flask(_name_) @app.route('/') def index(): return '<h1> Hello from Python flask!</h1>' if _name_ == '_main_': app.run(debug=True) # app.run()========================================================
Python 3.11.5 (tags/v3.11.5:cce6ba9, Aug 24 2023, 14:38:34) [MSC v.1936 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license()" for more information.
= RESTART: C:\PYTHON\Workbench\Hello.py
Error:Traceback (most recent call last):
File "C:\PYTHON\Workbench\Hello.py", line 2, in <module>
app = Flask(_name_)
NameError: name '_name_' is not defined. Did you mean: '__name__'?
Larz60+ write Nov-05-2023, 09:43 PM:
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Code modified for you this time. Please use BBCode tags on future posts.
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Code modified for you this time. Please use BBCode tags on future posts.