Let's see what a minimal Flask application looks like:
from flask import Flask
app = Flask(__name__)
@app.route('/')
def index():
return 'Hello World!'
That's it, we are done with the minimal Flask application. It's very simple to configure and create a microservice with Flask.
Let's discuss what exactly the preceding code is doing and how we would run the program:
- First, we imported a Flask class.
- Next, we created an instance of the Flask class. This instance will be our WSGI application. This first argument will be the name of the module or package. Here, we created a single module, hence we used __name__. This is needed so that Flask knows where to look for templates, static, and other directories.
- Then, we used app.route as a decorator with a URL name as a parameter. This will define and map the route with...