0PricingLogin
Flask Academy · Lesson

Return Strings, HTML, and Status Codes

Send different bodies and set HTTP status.

Returning a Plain String

The simplest response is a plain string. Flask sends it straight to the browser as the page body with a 200 status.

@app.route("/")
def home():
    return "Hello"

Strings Can Hold HTML

Your string can contain real HTML tags. The browser parses them, so returning a heading renders as a styled title, not as raw text.

return "<h1>Welcome</h1>"

All lessons in this course

  1. The @app.route Decorator
  2. How a Request Becomes a Response
  3. Return Strings, HTML, and Status Codes
  4. Multiple Routes in One App
← Back to Flask Academy