Creating RESTful web applications with Flask
Creating a simple RESTful web service or a web application with a set of RESTful applications with Python has never been easier. Now you can create a simple web service and make it run in a matter of minutes in Python.
Getting ready
This recipe depends on the third-party Python Flask
library. If it is not already available in your local Python installation, you can install this library using pip as follows:
$ pip install Flask
How to do it...
We can use the Flask
library to create simple RESTful web services and web applications without having to install any complex web service engines or web application containers.
Listing 7.7 gives the code for a simple web service that gets a number as an input to the RESTful service, and outputs the Fibonacci number and Square of the number:
#!/usr/bin/env python # Python Network Programming Cookbook, Second Edition -- Chapter - 7 # This program is optimized for Python 2.7.12 and Python 3.5.2. # It may run on...