Explanation:
from flask import Flask
Meaning:
You are importing the Flask class from the Flask library.
Purpose:
Flask is a micro web framework used to create web applications in Python.
This line lets you use Flask to build your app.
app = Flask(__name__)
Meaning:
You are creating a Flask application object named app.
__name__ explanation:
It tells Flask where your application’s code is located.
Purpose:
This object (app) will handle web requests and send back responses.
@app.route('/')
Meaning:
This is a route decorator — it connects a URL to a function.
'/' means the home page (the root URL).
Purpose:
When someone visits http://localhost:5000/, Flask will call the function below this line (index()).
def index():
Meaning:
Defines a Python function named index.
Purpose:
This function runs when the user opens the / route.
return "Hi"
Meaning:
This tells Flask to send the text "Hi" back to the browser.
Output:
When you open the page, you’ll see:
Hi
Final Result in Browser:
When you run the app and go to http://127.0.0.1:5000/
→ You’ll see the text Hi


0 Comments:
Post a Comment