Chapter 7. Implementing a Web Application with Python Using Flask

To ensure prosperity in the process of learning about the Requests module, there seems to be nothing more important than an application of all the skills and knowledge that you attained until now. So, here we pave the way to apply the expertise you have gained till date, by creating a web application with the Flask framework. This will give you an in-depth knowledge of developing a practical web application and writing test cases for it. We do incline ourselves towards following the best practices and a hands-on approach in this process. Let us dive in to learn the stuff.

What is Flask?

Flask is a small yet powerful framework for creating web applications with Python. It can be called a micro framework. It is so small that if you could build a good rapport with it, you can understand all of its source code. It is powerful because of its goodies called extensions and its ability to provide all the basic services as a whole. The extensions can be added according to the application's requirement. The man behind Flask framework is Armin Ronacher, who released it on April 1, 2010.

Flask goodies are as follows:

  • Flask comes up with an inbuilt development server, which assists you in the development process and in the testing of programs.
  • Error logging is made simple in Flask, with its interactive web-based debugger. When executing your code, if any bug has emerged in the way, an error stack trace will be shown on the web page, which makes it easy to deal with. This can be achieved by setting the flag of app.debug to True.
  • With its lightweight nature, Flask is a perfect framework to build RESTful web services. The route decorator which helps to bind a function to a URL can take the HTTP methods as arguments that pave a way to build API's in an ideal manner. In addition, working with JSON data is simple with Flask.
  • The template support for Flask is served by a flexible template engine called Jinja2. This makes the process of rendering the templates a smoother task.
  • The Session object is another goodie which saves the user's session. It stores the requests of the user so that the application can remember the different requests from the user.
  • Flask uses the Web Server Gateway Interface (WSGI) protocol while dealing with requests from clients and it is 100 % WSGI compliant.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.15.154