Python New Web Frameworks Introduction

In this Python article iam going to have Introduction in Python New Web Frameworks, if you are a python developer you will be familiar with Django and Flask, the most popular web frameworks for python programming language.

but in this video we are not going to talk about django or flask, we are going to talk about the new web frameworks for python.

 

1: Starlette

Starlette is a lightweight ASGI framework/toolkit, which is ideal for building high performance asyncio services.

It is production-ready, and gives you the following:

  • Seriously impressive performance.
  • WebSocket support.
  • GraphQL support.
  • In-process background tasks.
  • Startup and shutdown events.
  • Test client built on requests.
  • CORS, GZip, Static Files, Streaming responses.
  • Session and Cookie support.
  • 100% test coverage.
  • 100% type annotated codebase.
  • Zero hard dependencies.

 

Requirements 

Python 3.6+

 

Installation

 

Example:

 

Then run the application using Uvicorn:

 

Starlette on GitHub

 

 

2: Blacksheep

BlackSheep is an asynchronous web framework to build event based, non-blocking Python web applications. It is inspired by FlaskASP.NET Core, and the work by Yury Selivanov.

 

Installation

 

Example:

 

Requirements 

BlackSheep belongs to the category of ASGI web frameworks, so it requires an ASGI HTTP server to run, such as uvicorndaphne, or hypercorn. For example, to use it with uvicorn:

 

 

To run an application like in the example above, use the methods provided by the ASGI HTTP Server: server is the name of our python file.

 

BlackSheep on GitHub

 

 

3: Sanic

Sanic is a Python 3.6+ web server and web framework that’s written to go fast. It allows the usage of the async/await syntax added in Python 3.5, which makes your code non-blocking and speedy.

The project is maintained by the community, for the community. Contributions are welcome!

The goal of the project is to provide a simple way to get up and running a highly performant HTTP server that is easy to build, to expand, and ultimately to scale.

 

Installation

 

 

Example:

Sanic on GitHub

 

 

4: FastAPI

FastAPI is a modern, fast (high-performance), web framework for building APIs with Python 3.6+ based on standard Python type hints.

The key features are:

  • Fast: Very high performance, on par with NodeJS and Go (thanks to Starlette and Pydantic). One of the fastest Python frameworks available.
  • Fast to code: Increase the speed to develop features by about 200% to 300% *.
  • Fewer bugs: Reduce about 40% of human (developer) induced errors. *
  • Intuitive: Great editor support. Completion everywhere. Less time debugging.
  • Easy: Designed to be easy to use and learn. Less time reading docs.
  • Short: Minimize code duplication. Multiple features from each parameter declaration. Fewer bugs.
  • Robust: Get production-ready code. With automatic interactive documentation.
  • Standards-based: Based on (and fully compatible with) the open standards for APIs: OpenAPI (previously known as Swagger) and JSON Schema.

* estimation based on tests on an internal development team, building production applications.

 

Installation

 

You will also need an ASGI server, for production such as Uvicorn or Hypercorn.

 

Example:

Run the server with:

FastAPI on GitHub

 

 

5: Klein

Klein is a micro-framework for developing production-ready web services with Python. It is ‘micro’ in that it has an incredibly small API similar to Bottle and Flask. It is not ‘micro’ in that it depends on things outside the standard library. This is primarily because it is built on widely used and well tested components like Werkzeug and Twisted.

Klein bottle is an example of a non-orientable surface, and a glass Klein bottle looks like a twisted bottle or twisted flask. This, of course, made it too good of a pun to pass up.

Klein’s documentation can be found at Read The Docs.

 

Installation

 

Example:

Klein on GitHub

 

 

6: Quart

Quart is a Python ASGI web microframework. It is intended to provide the easiest way to use asyncio functionality in a web context, especially with existing Flask apps. This is possible as the Quart API is a superset of the Flask API.

Quart aims to be a complete web microframework, as it supports HTTP/1.1, HTTP/2 and websockets. Quart is very extendable and has a number of known extensions and works with many of the Flask extensions.

 

Installation

Quart can be installed via pipenv or pip,

 

Example:

if the above is in a file called app.py it can be run as,

Quart on GitHub

 

 

Also you can watch the video for this article

 

Subscribe and Get Free Video Courses & Articles in your Email

 

Share via
Copy link
Powered by Social Snap
×