0Pricing
Python Academy · Lesson

Routes and Views

Handle HTTP requests.

What is Flask?

Flask is a lightweight Python web framework. It lets you build web apps and APIs with very little boilerplate. Install it with pip install flask.

from flask import Flask
app = Flask(__name__)
print('Flask app created:', app.name)

Creating the App

Every Flask app starts with an app = Flask(__name__) object. The __name__ argument helps Flask locate resources like templates.

from flask import Flask
app = Flask(__name__)
if __name__ == '__main__':
    # app.run() starts the development server
    print('App is ready to run')

All lessons in this course

  1. Routes and Views
  2. Templates with Jinja2
  3. Forms and Request Data
  4. Building a REST Endpoint
← Back to Python Academy