Nov-05-2023, 03:56 PM
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__'?