How to Build Your First Flask Web App in Python (Hello, World!)

Day 32 of 100 Days Coding Challenge: Python

Today I met Flask—and no, not the kind you sneak whiskey into conferences with. This one is a web framework, and it’s my first real step into the world of web applications. At first glance, the code looked suspiciously simple: import Flask, create an app, slap a “Hello, World!” on the screen. That’s it? Really?

But behind that humble greeting lies a whole new realm of possibilities. I’m already plotting how to use this for my future AI projects. Imagine wrapping a Python model into a sleek web interface—Flask makes that not just possible but practically inviting. For now, I’m staying in my lane and keeping it small. One “hello world” at a time. Baby steps, but hey, even Iron Man had to build his first suit in a cave.

Today’s Motivation / Challenge

Building websites sounds like something best left to Silicon Valley wizards, but today proved it doesn’t have to be. Flask gives you a gentle nudge into the web world, perfect for anyone who’s ever wanted to turn a Python script into something users can actually interact with. No dragons to slay, just a server to run.

Purpose of the Code (Object)

This little project sets up a tiny website on your computer that proudly displays “Hello, World!” when you visit it in a browser. It’s the classic starter app, but this time, you’re doing it with your own Python magic. Think of it as shaking hands with the Internet.

AI Prompt

Make a Flask app that runs a server on localhost and displays “Hello, World!” on the homepage.

Functions & Features

  • Runs a basic web server locally
  • Displays a message (“Hello, World!”) when you open the site
  • Prepares the foundation for future web-based apps

Requirements / Setup

pip install flask

Minimal Code Sample

from flask import Flask  

app = Flask(__name__)  

@app.route(‘/’)  

def hello():  

    return ‘Hello, World!’  

This sets up a web route at / and returns a greeting when accessed.

Flaskapp

Notes / Lessons Learned

This was surprisingly fun. I’ve never built a web app before, but now I’ve got a tiny server cheering me on from my browser tab. There’s a lot more to learn—routing, templates, maybe even form handling—but I already see how this can be the launchpad for my AI work. I’ve been tinkering with Python models in isolation, but now I can give them a proper front door. The best part? I didn’t need a massive framework or a team of developers. Just me, Flask, and a mildly confused browser.

Optional Ideas for Expansion

  • Change the greeting based on the time of day
  • Add a new route, like /about, to test routing
  • Connect it to an AI model that responds with something witty (or weird)