logo

Flask getting started: Hello World

In this tutorial you’ll learn how to build a web app with Python.

We’ll use a micro-framework called Flask. It has a small core but is extensible with many plugins such as SQLAlchemy, Babel, CouchDB, MongoDB etc.

Some Flask example apps are:


Related course
Python Flask: Make Web Apps with Python

Why Flask?

  • easy to use.
  • built in development server and debugger
  • integrated unit testing support
  • RESTful request dispatching
  • uses Jinja2 templating
  • support for secure cookies (client side sessions)
  • 100% WSGI 1.0 compliant
  • Unicode based
  • extensively documented

Download Flask Examples

Installing Flask

Install Flask using the command below:

pip install Flask

Flask hello world app


Create a file called hello.py


from flask import Flask
app = Flask(__name__)

@app.route("/")
def hello():
return "Hello World!"

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

Finally run the web app using this command:

$ python hello.py
* Running on http://localhost:5000/

Open http://localhost:5000/ in your webbrowser, and “Hello World!” should appear.

Download Flask Examples

Next

4 thoughts on “Flask getting started: Hello World


  1. Michael
    - August 21, 2015

    can i ask any question frank?

    1. Frank
      - August 21, 2015

      sure, ask anything you want.

  2. Robert Walsh
    - July 17, 2015

    what if flask will not install on python?

    1. Frank
      - July 17, 2015

      You can install Flask with pip, easy_install or another tool depending on your operating system.

Leave a Reply

Login disabled