O'Reilly logo

Python Requests Essentials by Bala Subrahmanyam Varanasi, Rakesh Vidya Chandra

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Getting started with Flask

We can kick-start our application development with a simple example, which gives you an idea of how we program in Python with a flask framework. In order to write this program, we need to perform the following steps:

  1. Create a WSGI application instance, as every application in Flask needs one to handle requests from the client.
  2. Define a route method which associates a URL and the function which handles it.
  3. Activate the application's server.

Here is an example which follows the preceding steps to make a simple application:

from flask import Flask
app = Flask(__name__)

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

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

In the preceding lines of code, we have created a WSGI application instance ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required