Best examples of 3 practical examples of creating a basic Flask application

If you’re learning Flask, staring at a blank `app.py` file can feel weirdly intimidating. The fastest way to get comfortable is to look at real, working code and build from there. That’s why in this guide we’ll walk through the best examples of 3 practical examples of creating a basic Flask application, then expand those ideas into several more real-world mini-projects. Instead of abstract theory, you’ll see examples of everyday things you might actually build: a tiny API, a form-based app, and a micro dashboard. Along the way, we’ll talk about how these examples of 3 practical examples of creating a basic Flask application fit into modern 2024–2025 trends like lightweight APIs, single-page tools, and quick internal apps for teams. You’ll get copy‑pasteable snippets, clear explanations, and ideas for extending each project. By the end, you’ll have not just three, but multiple concrete examples you can adapt for your own side projects, portfolios, or work tools.
Written by
Taylor
Published

1. Hello World, but Actually Useful

Everyone starts with "Hello, World!", but let’s turn it into something slightly more practical. This is the simplest of our examples of 3 practical examples of creating a basic Flask application, and it sets the stage for everything else.

Here’s a tiny app that greets a user by name using a URL parameter:

from flask import Flask

app = Flask(__name__)

@app.route("/")
def home():
    return "Welcome to my Flask app!"

@app.route("/hello/<name>")
def hello(name):
    return f"Hello, {name.capitalize()}!"

if __name__ == "__main__":
    app.run(debug=True)

Run this with python app.py, then visit:

  • http://127.0.0.1:5000/Welcome to my Flask app!
  • http://127.0.0.1:5000/hello/alexHello, Alex!

This first example of a basic Flask application teaches you:

  • How to create an app object
  • How to define routes with @app.route
  • How to use dynamic URL segments like <name>

It looks tiny, but every more advanced project you build in 2024 or 2025 will still follow this same pattern: import Flask, create app, define routes, run the server.


2. A Simple JSON API (One of the Best Examples for Modern Apps)

Modern web development is API-heavy. Single-page apps, mobile apps, and even internal tools often just need a clean JSON API. So one of the best examples of 3 practical examples of creating a basic Flask application is a super small JSON service.

Here’s a micro API that returns a list of tasks:

from flask import Flask, jsonify, request

app = Flask(__name__)

tasks = [
    {"id": 1, "title": "Learn Flask", "done": False},
    {"id": 2, "title": "Build a small API", "done": False},
]

@app.route("/api/tasks", methods=["GET"])
def get_tasks():
    return jsonify(tasks)

@app.route("/api/tasks", methods=["POST"])
def create_task():
    data = request.get_json()
    new_id = max(task["id"] for task in tasks) + 1 if tasks else 1
    task = {"id": new_id, "title": data.get("title", "Untitled"), "done": False}
    tasks.append(task)
    return jsonify(task), 201

if __name__ == "__main__":
    app.run(debug=True)

Now you can:

  • GET /api/tasks → get all tasks
  • POST /api/tasks with JSON like { "title": "Ship my first Flask app" } → create a new task

This is one of the real examples that feels close to what developers ship at work: a tiny internal API for a team to track something. Extend it with authentication, a database, or filtering, and you’re already in “portfolio-ready” territory.

If you want to go deeper on HTTP and APIs, the official MDN Web Docs from Mozilla are a great reference: https://developer.mozilla.org/en-US/docs/Web/HTTP


3. Handling Forms: A Mini Feedback App

Forms are where Flask starts feeling like a real web framework instead of a toy. In this third piece of our examples of 3 practical examples of creating a basic Flask application, you’ll build a tiny feedback form that accepts user input and shows it back.

from flask import Flask, request, render_template_string

app = Flask(__name__)

TEMPLATE = """
<!doctype html>
<title>Feedback</title>
<h1>Leave Feedback</h1>
<form method="post">
  <label>Your name:</label><br>
  <input name="name"><br><br>
  <label>Your feedback:</label><br>
  <textarea name="feedback"></textarea><br><br>
  <button type="submit">Submit</button>
</form>

{% if name %}
  <h2>Thanks, {{ name }}!</h2>
  <p>You said: {{ feedback }}</p>
{% endif %}
"""

@app.route("/feedback", methods=["GET", "POST"])
def feedback():
    name = None
    feedback_text = None

    if request.method == "POST":
        name = request.form.get("name")
        feedback_text = request.form.get("feedback")

    return render_template_string(TEMPLATE, name=name, feedback=feedback_text)

if __name__ == "__main__":
    app.run(debug=True)

This example of a basic Flask application shows you how to:

  • Accept both GET and POST on the same route
  • Read form data from request.form
  • Use a simple inline template with Jinja2 placeholders

In real projects, you’d move the HTML into a separate templates folder and use render_template, but the structure would stay the same.


Expanding Beyond 3: More Real Examples You Can Reuse

The phrase “examples of 3 practical examples of creating a basic Flask application” sounds limiting, but in reality each of those three ideas can branch into many more mini-projects. Let’s walk through several real examples that build on the same patterns.

A Tiny Weather Lookup Service

This example of a Flask app calls an external API and returns a cleaned-up response. In 2024–2025, this pattern is everywhere: small services that wrap third-party APIs.

import os
import requests
from flask import Flask, request, jsonify

app = Flask(__name__)

WEATHER_API_KEY = os.getenv("WEATHER_API_KEY")

@app.route("/api/weather")
def weather():
    city = request.args.get("city", "New York")
    url = "https://api.open-meteo.com/v1/forecast"
    params = {"latitude": 40.7128, "longitude": -74.0060, "current_weather": True}
    response = requests.get(url, params=params, timeout=5)
    data = response.json()

    return jsonify({
        "city": city,
        "temperature_c": data.get("current_weather", {}).get("temperature"),
        "windspeed": data.get("current_weather", {}).get("windspeed"),
    })

if __name__ == "__main__":
    app.run(debug=True)

You could adapt this to show weather for different cities, cache results, or feed the data into a front-end dashboard.

For background on web APIs and open data, the U.S. General Services Administration maintains helpful resources at https://open.gsa.gov/developer/

A Micro Habit Tracker

Habits and wellness apps are everywhere. Here’s a simple example of a Flask app that tracks habits in memory:

from flask import Flask, request, jsonify

app = Flask(__name__)

habits = []

@app.route("/api/habits", methods=["GET", "POST"])
def handle_habits():
    if request.method == "POST":
        data = request.get_json()
        habit = {
            "name": data.get("name"),
            "times_done": 0
        }
        habits.append(habit)
        return jsonify(habit), 201
    return jsonify(habits)

@app.route("/api/habits/<int:index>/done", methods=["POST"])
def mark_done(index):
    try:
        habits[index]["times_done"] += 1
        return jsonify(habits[index])
    except IndexError:
        return jsonify({"error": "Habit not found"}), 404

if __name__ == "__main__":
    app.run(debug=True)

This uses the same patterns as our earlier examples of 3 practical examples of creating a basic Flask application, but now you’re building something that could connect to a front-end, or even a mobile app, as a genuine backend.

If you’re pairing coding with behavior change or health-related tracking, it’s always worth reviewing evidence-based resources like the NIH’s health topics pages: https://www.nih.gov/health-information

A Minimal Admin Dashboard for Internal Data

Many teams in 2024–2025 use Flask for lightweight internal dashboards: think “spreadsheet with a URL.” Here’s a stripped-down dashboard showing some fake sales stats:

from flask import Flask, render_template_string

app = Flask(__name__)

STATS_TEMPLATE = """
<!doctype html>
<title>Sales Dashboard</title>
<h1>Sales Overview</h1>
<ul>
  <li>Today: ${{ stats.today }}</li>
  <li>This Week: ${{ stats.week }}</li>
  <li>This Month: ${{ stats.month }}</li>
</ul>
"""

@app.route("/dashboard")
def dashboard():
    stats = {
        "today": 1250.50,
        "week": 8420.75,
        "month": 32100.10,
    }
    return render_template_string(STATS_TEMPLATE, stats=stats)

if __name__ == "__main__":
    app.run(debug=True)

Again, this is another real example of how the same core ideas from the examples of 3 practical examples of creating a basic Flask application can be reused to build something business-friendly.


Flask is still popular in 2024–2025 because it stays small and flexible. Instead of forcing a giant structure on you, it lets you start with tiny projects like the examples of 3 practical examples of creating a basic Flask application in this guide, then grow them as needed.

Today, developers often use Flask for things like:

  • Small JSON APIs for front-end frameworks
  • Quick prototypes to validate ideas
  • Internal dashboards for operations or analytics
  • Teaching HTTP, routing, and templates in classrooms

Universities and bootcamps still lean on Flask for intro web courses because the learning curve is gentle and the code stays readable. For example, many academic web programming courses reference patterns very similar to these examples. You can see the style of educational material at places like Harvard’s CS50 course site: https://cs50.harvard.edu/

If you understand the patterns behind these real examples, you’re already well-positioned to build more advanced apps that add authentication, databases, background jobs, and deployment.


Putting It All Together: From Toy Apps to Real Projects

Let’s connect the dots between the examples of 3 practical examples of creating a basic Flask application and what you might actually want to ship.

The greeting app shows you routing and URL parameters. The JSON API teaches you how to expose data for other clients. The feedback form introduces user input and templates. The weather service, habit tracker, and dashboard demonstrate how those same building blocks combine into real examples that feel like actual products.

You can mix and match these patterns:

  • Build a feedback form that stores submissions in a database and exposes them via a JSON API
  • Turn the habit tracker into a dashboard with charts using a front-end library
  • Wrap any third-party API (weather, finance, sports) in a clean Flask route and share it with your team

Each time you create a new example of a Flask application, you’re mostly reusing the same concepts you saw in those first three practical examples.

If you keep your apps small, focused, and readable, they’ll be easier to maintain and easier to explain in interviews or portfolio write-ups.


FAQ: Short Answers for Common Flask Beginner Questions

What are some examples of basic Flask applications I can build as a beginner?

Some great starter projects include a greeting app with dynamic URLs, a small JSON task API, a feedback form app, a weather lookup service, a micro habit tracker, and a simple internal stats dashboard. These are all real examples that build directly on the same patterns you saw in the examples of 3 practical examples of creating a basic Flask application above.

Can I turn these examples into production apps?

Yes, but you’ll want to add things like error handling, logging, configuration management, and a real database. You’ll also want to run Flask behind a production server like Gunicorn or uWSGI. The core patterns from each example of a basic Flask application stay the same; you just harden them for real-world use.

Do I need a frontend framework to use Flask?

No. Many of the best examples of small Flask apps in the wild use plain HTML templates with Jinja2. Later, you can connect React, Vue, or another framework to your JSON routes if you want a richer interface.

Is Flask still worth learning in 2024–2025?

Absolutely. Flask remains popular for teaching, rapid prototyping, and microservices. The fact that you can learn so much from small, focused examples of 3 practical examples of creating a basic Flask application makes it a friendly starting point that still scales to serious work.

Where can I learn more about HTTP, security, and web basics while using Flask?

For HTTP and web fundamentals, MDN Web Docs (Mozilla) is excellent. For security and safe coding practices, government and educational resources like the Cybersecurity & Infrastructure Security Agency (CISA) at https://www.cisa.gov/ and university course materials (for example, Harvard’s CS50 site) are helpful companions as your Flask apps grow beyond the basics.

Explore More Flask Code Snippets

Discover more examples and insights in this category.

View All Flask Code Snippets