0
0
Flaskframework~15 mins

What is Flask - Hands-On Activity

Choose your learning style9 modes available
What is Flask
📖 Scenario: You want to create a simple web application that shows a greeting message on a webpage.
🎯 Goal: Build a basic Flask app that displays 'Hello, Flask!' when you visit the homepage.
📋 What You'll Learn
Create a Flask app instance named app
Define a route for the homepage using @app.route('/')
Create a function home that returns the string 'Hello, Flask!'
Run the Flask app with app.run()
💡 Why This Matters
🌍 Real World
Flask is used to build websites and web services quickly and simply, like blogs, portfolios, or APIs.
💼 Career
Knowing Flask helps you create backend web applications and APIs, a valuable skill for Python developers.
Progress0 / 4 steps
1
Set up Flask app instance
Import Flask from the flask module and create a Flask app instance called app.
Flask
Need a hint?

Use from flask import Flask and then app = Flask(__name__).

2
Define homepage route
Use the @app.route('/') decorator to define a route for the homepage.
Flask
Need a hint?

Use @app.route('/') just before the function that handles the homepage.

3
Create homepage function
Define a function called home that returns the string 'Hello, Flask!'.
Flask
Need a hint?

Write def home(): and inside it return 'Hello, Flask!'.

4
Run the Flask app
Add app.run() at the end to start the Flask development server.
Flask
Need a hint?

Simply add app.run() to start the server.