0
0
Flaskframework~5 mins

Why Flask as a micro-framework

Choose your learning style9 modes available
Introduction

Flask is a small and simple tool to build web apps quickly. It gives you just the basics so you can add only what you need.

You want to create a simple website or API fast without extra features.
You prefer to control which parts to add instead of using a big, full system.
You are learning web development and want to understand how things work step-by-step.
You need a lightweight app that runs with minimal setup and dependencies.
Syntax
Flask
from flask import Flask
app = Flask(__name__)

@app.route('/')
def home():
    return 'Hello, Flask!'

if __name__ == '__main__':
    app.run()

Flask(__name__) creates the app object.

@app.route('/') sets the URL path for the function below.

Examples
This example shows how to add a new page at '/about'.
Flask
from flask import Flask
app = Flask(__name__)

@app.route('/about')
def about():
    return 'About page'

if __name__ == '__main__':
    app.run()
This example uses a variable in the URL to greet different users.
Flask
from flask import Flask
app = Flask(__name__)

@app.route('/user/<name>')
def user(name):
    return f'Hello, {name}!'

if __name__ == '__main__':
    app.run()
Sample Program

This simple Flask app shows a welcome message on the home page. Running it starts a small web server you can visit in your browser at http://127.0.0.1:5000/.

Flask
from flask import Flask
app = Flask(__name__)

@app.route('/')
def home():
    return 'Welcome to Flask Micro-framework!'

if __name__ == '__main__':
    app.run(debug=True)
OutputSuccess
Important Notes

Flask is called a micro-framework because it keeps things small and simple.

You can add extra tools later as your app grows.

Flask is great for beginners and small projects.

Summary

Flask gives you a simple start to build web apps.

It lets you add only what you need, keeping things light.

Perfect for learning and small to medium projects.