---
title: "Flask Quickstart"
date: "2015-03-08"
category: "python"
slug: "flask-quickstart"
---

## Overview

[Flask](http://flask.pocoo.org/) is a Python microframework for building web applications with minimal overhead. It is a lightweight alternative to Django with fewer built-in features but better speed. Flask is supported on [[determining-platform-version]] using [Passenger](http://www.phusionpassenger.com).

## Quickstart

All steps are performed from the [[accessing-terminal]]. While it may be possible to deploy Flask without terminal access, it is strongly recommended.

1. Create a [[passenger-application-layout]] filesystem layout.
2. Change to the base directory (we'll use `flask` under `/var/www`):
    - `cd /var/www/flask`
3. _Optional:_ Select a [[changing-python-versions]] using pyenv.
4. Install Flask using [[installing-packages]]:
    - pip install flask
        
5. Create a Passenger startup file (`passenger_wsgi.py`) to run Flask as a [[using-wsgi]] application:
    - from flask import Flask
        application = Flask(\_\_name\_\_)
         
        @application.route("/")
        def hello():
         return "Hello World!"
        
        if \_\_name\_\_ == "\_\_main\_\_":
         application.run()
        
    - **Important:** This is identical to the standard Flask "Hello World" example, except `app` is renamed to `application`. Passenger requires the WSGI entry point to be named `application`.
6. Connect `public/` to a subdomain in the control panel under **Web** > **Subdomains**.
7. Access your subdomain to see Flask running.

## Restarting a Flask App

Flask runs through Passenger, so use the standard [[restarting-passenger-processes]] method.

## See Also

- [Explore Flask](https://exploreflask.com/) eBook
- [Flask documentation](http://flask.pocoo.org/docs/latest/)
- [Django vs Flask vs Pyramid](https://www.airpair.com/python/posts/django-flask-pyramid)
- [Flask demo](http://flask.sandbox.apnscp.com/) running on a v6 account
