0Pricing
Flask Academy · Lesson

Hello World: Your First Flask App

Write app.py and create the Flask application object.

Hello World: Your First Flask App is a free Flask Academy lesson on CoddyKit — lesson 3 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Flask Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

Time to Build

You will now write your first Flask app and return a real response. It is just a few lines, and you already have everything installed. 🙌

Create app.py

Make a file named app.py in your project folder. This single file will hold your tiny first application.

Import Flask

Start by importing the Flask class. Everything you build hangs off the app object you are about to create.

from flask import Flask

Create the App Object

Instantiate Flask and pass __name__ so it knows where your app lives and can locate templates and static files.

app = Flask(__name__)

What __name__ Does

The __name__ value tells Flask the import name of your module, which it uses to resolve resource paths correctly.

Add a Route

The @app.route decorator ties a URL path to the function right below it. Here the homepage path is just a slash.

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

The View Function

The function under a route is a view. Whatever string it returns becomes the body the browser displays.

Return a Response

Returning plain text is the simplest response. Flask wraps your string in a proper HTTP response automatically. 📨

The Main Guard

An if __name__ block lets you run the file directly. Inside it you call app.run to start the development server.

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

Run Your App

Launch it from the terminal. Flask prints a local address, usually on port 5000, where your app is now listening.

python app.py

See It in the Browser

Open http://127.0.0.1:5000 and your greeting appears. You just served your first web page with Python.

Quick Check

Quick check on wiring up your first app.

Recap

You imported Flask, built the app object, added a route and view, and ran it. Hello World is live in your browser. 🌍

Frequently asked questions

Is the “Hello World: Your First Flask App” lesson free?

Yes — the full text of “Hello World: Your First Flask App” is free to read here on the web, and the Flask Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Flask Academy course, upgrade to CoddyKit PRO.

What will I learn in “Hello World: Your First Flask App”?

Write app.py and create the Flask application object. You practise Flask Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start Flask Academy?

No prior experience is required. Flask Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 3 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “Hello World: Your First Flask App” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this Flask Academy lesson?

Yes. Every Flask Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. What Flask Is and Why It Exists
  2. Set Up a Virtualenv and Install Flask
  3. Hello World: Your First Flask App
  4. Run the Dev Server with Debug Mode
← Back to Flask Academy