Running a simple application (Simple)

Let's get started by running a simplest Flask application.

Getting ready

Make sure you have activated your virtualenv tool as described in the previous section.

How to do it...

  1. Put this code into a file named
    from flask import Flask
    app = Flask(__name__)
    def hello():
        return 'Hello, world!'
    if __name__ == '__main__':
  2. Run this application from the console:
    $ python
  3. If this runs correctly, you will see:

    * Running on

    This is a URL, which you can visit in your browser. When you do, your browser will display a plain page which says "Hello, world!" (without quotes). Note that the address refers to localhost, such that Flask will only respond to ...

Get Instant Flask Web Development now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.