June 2017
Beginner to intermediate
274 pages
6h 49m
English
There are actually two ways to make Flask handle a request: one way is incredibly simple and the other is more flexible and better encapsulated.
The simpler way is to use the @app.route decorator to tell Flask that a particular function will handle requests for a given path, as shown in the following code example:
@app.route('/example')
def example():
return "This is an example"
That's all that's needed, apart from making the function actually do something useful.
However, for our microservice, we want to use HTTP methods on the same path to produce different results. We can use an app.route decorator and a bunch of if and else if blocks in the function to handle that, but there's a better way, which is explained ...
Read now
Unlock full access