Q: What exactly is a Web framework? A: Web frameworks are mainly used for website development. Developers implement their own business logic based on web frameworks. Web frameworks implement many functions and provide a common method for implementing business logic.
Q: What is the role of Web framework? A: Using the Web framework, many functions other than business logic do not need to be improved by yourself. Instead, you can use the existing functions of the framework. Web frameworks reduce the workload when developing websites.
Q: Why should we use web frameworks? A: Web framework is mainly used for website development, which can realize data interaction and improve business functions. When using a Web framework for website development, you do not need to re-implement it yourself in terms of data caching, database access, data security verification, etc. Instead, you can write the business logic-related code into the framework.
Library sorting is based on the number of users and document activity as a reference. It is recommended that you use the top-ranked frameworks because of their documentation It is more complete, has more technology accumulation, has a more prosperous community, and can get better support. In this way, when you encounter problems that you cannot solve, you can find solutions faster and more efficiently.
1. Django framework
Official website: https://www.php.cn/ link/f1903f234d3ba4da38a18aa25751457d
## Advantages: It is a high-level Python Web development framework, characterized by fast development, less code, and strong scalability. Django uses the MTV (Model, Template, View) model to organize resources. The framework has rich functions and the most template expansion options. For professionals, Django is undoubtedly the #1 web development framework for Python.
Disadvantages: It includes some functional modules that are not needed for lightweight applications and is not as lightweight as Flask. Over-encapsulation of many classes and methods makes them easier to use directly, but more difficult to change. Compared to C and C performance, Djang performance is low. Templates realize the complete separation of code and style, do not allow Python code to appear in templates, and are not flexible enough. In addition, the learning curve is relatively steep.
##2. Flask Framework
Official website:https://www.php.cn/link/d12f3b5c457a92abbc87939406df183f Advantages: Flask is a micro-framework for Python web development. Strictly speaking, it only provides web server support and does not provide full-stack development support. However, Flask is very lightweight and simple. It takes minutes to build a web system based on it, which is especially suitable for the development of small and micro prototype systems. It is a very cost-effective choice to spend less time and produce a usable system.
Disadvantages: For large-scale website development, routing mapping rules need to be designed, otherwise the code will be confusing. For newbies, it's easy to create "bad web applications" with low-quality code.
##3. Pyramid Framework
##Official website:
https://www.php.cn/link/9ec0cfdc84044494e10582436e013e64 Advantages: It is a highly scalable and flexible Python web development framework. It is very easy to get started and is more suitable for medium-scale scenarios where development and design are at the same time. Pyramid does not provide an absolutely strict framework definition and can be expanded and developed according to needs, making it very friendly to advanced programmers.
Disadvantages: It is not well-known in China. For advanced usage, you need to get inspiration from reading the source code. With the Chameleon template used by default, flexibility is not a factor.
##4. web.py framework Official website: https://www.php.cn/link/8d4112ce0aabe7aeef422c136a222624 Advantages: As its name suggests, web.py is a Web framework using Python as the development language, which is simple and powerful. Russia’s number one search engine, Yandex, is developed based on this framework. Guido van Rossum believes this is the best Python web framework. Need to say anything else? There are facts to prove it and experts to approve it, use it! Cons: Web.py is not kept up to date with Python 3 compatibility like other frameworks. Not only does this mean a lack of support for async syntax, it also means a lack of bugs for deprecated functions. Additionally, it's unclear whether the maintainers have plans to keep Web.py up to date after Python 2 reaches the end of its support lifecycle. ##5. Tornado Framework https://www.php.cn/link/76330c26dea62332de2ca7b4a9ef51ec Advantages: Tornado is a Web development framework based on an asynchronous network function library. Therefore, it can support tens of thousands of open connections and the Web service is efficient and stable. It can be seen that Tornado is suitable for web systems in high concurrency scenarios. The development process needs to use the framework provided by Tornado, which has poor flexibility. It is not too late to consider using it after determining the scenario. Cons: Tornado 5.0 has improved integration with Python’s native async features. Python 3.3 is therefore no longer supported, and Python 3.5 users must use Python 3.5.2 or higher. Tornado 6.0 will require Python 3.5 and above and will drop Python 2 support entirely. ##6. TurboGears Framework Official website : https://www.php.cn/link/ce1d2a5e1884a6c502a675dbd0d3928e Cons: Some disadvantages of TurboGears include basic management functionality, few third-party applications, and rudimentary documentation. One of the big challenges with TurboGears is how overwhelming it is. Because it provides unlimited flexibility when mixed with other components, it is overly complex when trying to decide which path to complete a task.
##7. CherryPy Framework Official website : https://www.php.cn/link/29056bc4790af32aa8458e3fbc737485##Advantages: CherryPy It allows developers to develop Web systems in accordance with similar design methods to other object-oriented programs, thereby using the least code and the most concise way. CherryPy has been developed for 10 years and has good stability. It is very suitable for small-scale web systems and pure Python programmers. What do you feel? Python has the potential to dominate the world! Let’s wait and see. Disadvantages: In addition to containing only the minimal content needed to serve the web page, it should try to feel as much as possible not like a "web framework" but like any other type Python applications. CherryPy contains bits that serve as low-level building blocks. Includes session identifiers and cookie handling, but does not include HTML templates. Like Bottle, CherryPy provides a way to map routes to directories on disk for serving static files.
##8. Falcon Framework :https://www.php.cn/link/ff8c1a3bd0c441439a0a081e560c85fc Advantages:Falcon is a support A web development framework for large-scale microservice API or mobile App backend response, which is completely based on Python and provides very high performance, reliability and scalability. Falcon has a unique positioning and distinctive features. For app developers, you may want to consider Falcon when building back-end systems. Nine times out of ten, you will not regret it. Disadvantages: Falcon’s disadvantage is that its packaging modules are a bit too few, including routing, middleware, and hooks, but other than that it does not provide other functions (bare shell). Additional functions, such as verification, require developers to develop extensions. Because it is designed to be used for building REST APIs.
##9. Asgineer Framework https://www.php.cn/link/e22c686bc771d5872150738b15f3e533## Asgineer is A tool for writing asynchronous web applications using as few abstractions as possible while still providing a friendly API. It only takes a few minutes to read the guide and reference materials! When running Asgineer on Uvicorn, it is one of the fastest web frameworks available. It supports http long polling, server side events (SSE) and websockets. And have the utility to service assets in the correct (and fast) way. Disadvantages: 10. Bottle Framework Official website: https ://www.php.cn/link/7bd87e2f279ba0141a9795e201bf1a53 Bottle is a fast, simple and A lightweight WSGI micro-network framework. It is distributed as a single file module with no dependencies other than the Python standard library. Supports clean and dynamic URLs. Fast and Pythonic built-in template engine with support for mako, jinja2 and cheetah templates. Easily access form data, file uploads, cookies, headers, and other HTTP-related metadata. Bottle One consequence of minimalism is that some features simply don’t exist. Form validation, including features such as CSRF protection, is not supported. If you want to build a web application that supports a high degree of user interaction, you'll need to add them yourself. Official website: https://www.php.cn/link/ffe10334251de1dc98339d99ae4743ba Write elegant code, Focus on your product, you should spend more time on your product rather than the underlying framework. Emmett is the inventor's framework because it is designed to simplify your development process with a simple syntax that is easy to learn and understand. Don't waste time between routers and uncomfortable modes: every time you write down the routes for your application, everything will appear clearly before your eyes. Disadvantages: Lack of Chinese documentation. 12. apidaora framework Official website: https://www.php.cn/link/c37a21223db1cda645af1264df751f7f## Advantages: Use type Annotations declare requests/responses as data classes and dictionaries, validate input data using jsondaora, one of the fastest python api frameworks that can run on any asgi server. #Disadvantages: Lack of Chinese documentation. 13. Quixote Framework Official website: https://www.php.cn/link/5f0453f78909173a7ce2eb874d2a7f52## Advantages: Quixote is A framework for writing web-based applications using Python. Its goals are flexibility and high performance, in that order. Quixote apps tend to be structured like traditional apps. The logic for formatting web pages consists of Python classes and functions. Quixote does not enforce separation of presentation logic and "backend" logic. Instead, we encourage you to use traditional techniques. For example, one solution is to put the presentation logic in its own sub-package. Disadvantages: Although Quixote is actively maintained, releases are less frequent. Recent development has focused on fixing bugs, improving standards compliance, and increasing Quixote's flexibility. Official website: https://www.php.cn/link/4e0ccd2b894f717df5ebc12f4282ee70 reahl is It is an open framework that allows developers to write web applications entirely in Python. The use of Python as the only development language is its biggest feature. In addition, reahl provides quite clear and concise development components, which are clear and feasible enough for developing general functional web systems. Disadvantages:
15. hug framework Official website: https://www.php.cn/link/e834cb114d33f729dbc9c7fb0c6bb607##Advantages: Hug is A Python 3 API development framework. It is designed so that software engineers can develop an API once and then use it again when needed. Hug framework simplifies API development by providing various interfaces. This is the main reason why this framework is known as one of the fastest frameworks in Python 3. Disadvantages: It uses the previous WSGI standard, which is a synchronous framework, so it cannot handle asynchronous requests like WebSockets and other, Regardless, it still performs very well.
16. BlackSheep Framework Official website: https ://www.php.cn/link/47bd8ac1becf213f155a82244b4a696a Advantages: BlackSheep is an asynchronous web framework for using Python Build event-based web applications. It is inspired by the work of Flask, ASP.NET Core, and Yury Selivanov. Disadvantages: Lack of Chinese documentation. 17. Index.py framework Official website: https://www.php.cn/link/374939012129c174e451f0f64be3bfea ##Advantages: Implements the ASGI3 interface and Use Radix Tree for route lookup. It is one of the fastest Python web frameworks. All features serve to quickly develop high-performance web services. It has a large number of correct type annotations, a flexible and efficient routing system, visual API interface and online debugging, supports Server-sent events and WebSocket, comes with one-click deployment commands (based on uvicorn and gunicorn), and can use any available ASGI ecosystem. Disadvantages: Index.py does not have built-in database, cache and other functions. If you have difficulty choosing, please use Django directly.
18. Sanic Framework Official website :https://www.php.cn/link/3b036b877a6a074d7dbfc706fe868c1d Advantages: Sanic is a Python 3.7 web server and web framework that is fast to write. It allows using the async/await syntax added in Python 3.5, which makes your code non-blocking and fast. The goal of this project is to provide a simple way to get up and running a high-performance HTTP server that is easy to build, scale, and eventually scale. Disadvantages: Sanic imitates Flask in terms of functionality, such as by sharing the concept of Blueprints, tiny sub-applications, allowing developers to Split and organize its code within a larger application. For CRUD applications that are just data additions, deletions, modifications, and queries, Sanic is not a good choice. ##19. Starlette Framework https://www.php.cn/link/818cdcf067c824a4e34f9293de3b15a9## Starlette is A lightweight ASGI framework/toolkit ideal for building performant asynchronous services that is production-ready and gives you the following: Impressive performance. WwbSocket support. GraphQL support. In-process background tasks. Start and shut down events. Test client built on requests. CORS, GZip, static files, streaming responses. Session and cookie support. 100% test coverage. 100% type annotated code base. Zero hard dependencies. Starlette provides all the basic web microframework functionality. But it does not provide automatic data validation, serialization or API documentation.
20. Fastapi Framework Official website: https ://www.php.cn/link/647a8664e3a3d945c87db2d07a6590c1 Advantages:FastAPI is a modern, fast (high-performance) Web framework for building APIs using Python 3.6 based on standard Python type hints. Very high performance, on par with NodeJS and Go (thanks Starlette and Pydantic). One of the fastest Python frameworks available. Reduce human (developer) induced errors by approximately 40%. Short, simple, intuitive, and robust. Disadvantages: does not come with template syntax and needs to be installed. 21. Responder Framework Official website: https://www.php.cn/link/212ab20dbdf4191cbcdcf015511783f4## Advantages: is newly developed by kennethreitz A project is an HTTP service framework based on Python. The bottom layer uses the Starlette framework. Starlette is a lightweight ASGI framework/toolkit. Starlette can be used to build high-performance asynchronous IO services. Compared to Starlette, responder is more developer-friendly. kennethreitz wrote requests called "HTTP for Humans" to make this clearer. In fact, in comparison, responder is much more elegant than Starlette. Disadvantages: may be a new project, and the packaging is not perfect yet. As of the current version, some code doesn't work properly yet. However, the interface form has been defined and is expected to be added in later versions. 22. Molten Framework Official website: https:// www.php.cn/link/b87039703fe79778e9f140b78621d7fb Advantages:Molten is minimal, scalable, fast and efficient A framework for building HTTP APIs using Python. Plans automatically validate requests and the code is easier to maintain. Instances are automatically serializable, contain the kinds of functionality the API typically requires in the real world, and make extensive use of PEP484 type hints and mypy. Disadvantages: It does not use third-party libraries like Pydantic to provide data validation, serialization and documentation, it has its own library. Therefore, these data type definitions will be less easily reusable. The dependency injection system requires pre-registration of dependencies and will resolve dependencies based on declared types. Therefore, it is not possible to declare multiple components to provide a specific type. 23. Clastic Framework Official website: https://www.php.cn/link/9fa04f87c9138de23e92582b4ce549ec ##Advantages: One function A powerful Python web framework that simplifies explicit development practices while eliminating global state. Clastic is written entirely in Python and features enhanced reusability and testability, proactive URL routing checks, better control over application initialization, improved middleware paradigm, no global state, ORM usage, easier WSGI integration. Disadvantages: Clastic does not build global state; URL routing rule parameters and view function signatures do not match. In Clastic, this mismatch will cause an exception when building the application . 24. Aiohttp framework Official website: https ://www.php.cn/link/6f8805c87ad80ed936bcd5ce4bebe65d Advantages: Asynchronous HTTP client for asyncio and Python/ server. Supports client and HTTP servers, supports server WebSockets and client WebSockets out of the box, no callback hell. The web server has middleware, signals, and pluggable routing. Disadvantages: According to RFC 7231 aiohttp 2.0 version made adjustments to accept HEAD requests, use the previous version and use add_get () to add the request , if accessed using the HEAD method, 405 will be returned. If the processor will write a lot of response body content, you can skip processing the response body content when executing the HEAD method to improve execution efficiency. 25. Masonite Framework Official website: https://www.php.cn/link/81baadacf39a11c56ee30acd5455fced Advantages: Modern and developer-oriented A Python-centric web framework dedicated to implementing real-world batteries, including developer tools with many out-of-the-box features, and an extremely extensible architecture. Masonite is great for beginner developers getting into their first web applications, as well as experienced developers who need to leverage the full potential of Masonite to complete their applications. Masonite strives to be fast and easy from installation to deployment, so developers can go from concept to creation as quickly and efficiently as possible. Use it for your next SaaS! Try it once and you'll fall in love. Disadvantages: For Masonite, the biggest "competitor" is Django, because the community is doing its best to push the framework to be easier , the delightful next big thing. Compared to Django, Masonite is still a baby, so look forward to its future performance. 26. Quart Framework Official website: https://www.php.cn/link/f7426bc1998891cd172a10233b83a8de## Advantages: Quart is A Python networking microframework. Using Quart, you can render and serve HTML templates, write (RESTful) JSON APIs, serve WebSockets, stream request and response data, and do almost anything over the HTTP or WebSocket protocols. Disadvantages: It only supports Python 3.7. 27. Tonberry Framework :https://www.php.cn/link/2342d8a616837cd6d79017fe68172b28 #Advantages: An ASGI-compliant Web micro-framework , using a class-based routing approach. Influenced by CherryPy but compatible with asyncio. A companion ASGI server called Qactuar emerged from this currently ongoing project. Disadvantages: When using pull requests, please use the automatic formatters iSort and Black and use MyPy to verify the code. This is without eliminating some type errors, which won't always make MyPy completely happy, but at least do your best and use the annotation `# type: ignore` sparingly. Finally, try to provide the most accurate type hints possible.
28. cyclone framework official website :https://www.php.cn/link/ed582716bfb4738ccd92405301122e66 Advantages: Cyclone is a Python web server framework that implements the Tornado API as the Twisted protocol. Twisted is an event-driven Python network programming framework. It is one of the most mature non-blocking I/O libraries available to the public. Tornado is the open source version of the FriendFeed web server, one of the most popular and fastest Python web servers with a very nice API for building web applications. In addition to its rich feature set, Cyclone also solves the C10K problem. Disadvantages: Cyclone no longer supports python 2.x. 29. Klein Framework ##Official website: https ://www.php.cn/link/fd9e2ae32b53addc06c63208be3aaa43 Advantages: Klein is a micro-framework for development using Python Production-ready web services. It is "micro" in that it has a very small API similar to Bottle and Flask. It's not "micro" because it relies on things outside the standard library. This is mainly because it is built on widely used and well-tested components such as Werkzeug and Twisted. Disadvantages: Maybe a little outdated. 30. nameko framework Official website: https://www.php.cn/link/5c341d10c5596a0fd920fda9f33bcb06## Advantages: AMQP RPC and events (publish-subscribe), HTTPGET, POST and websockets, CLI for easy and fast development, utilities for unit and integration testing. Disadvantages: nameko microservices will not automatically print error logs when errors occur, and monitoring-related dependencies need to be added, computing intensive Type tasks cause task retries. 31. CubicWeb Framework https ://www.php.cn/link/ff84a9f3c0d335d25413dd8dfc9b2e8f Advantages: CubicWeb is a semantic Web application framework that Licensed under the LGPL, it enables developers to efficiently build web applications by reusing components (called cubes) and following well-known object-oriented design principles. A library of reusable components (data models and views) for common needs, the power and flexibility of the Python programming language, the reliability of SQL databases, LDAP directories, Subversion and Mercurial for storage backends. Disadvantages: To obtain or manipulate persistent data in CubicWeb applications, you can use Relational Query Language (RQL). RQL provides a highly separated path to correlate various data with each other. source. However, as it is implemented, by manually building queries as strings, it may feel outdated to developers accustomed to ORMs. There are other obstacles to using CubicWeb. First, setup can be cumbersome. Another potential problem is the lack of a native template engine; generating HTML is left to the developer. CubicWeb supports Python 3, but modules like Twisted themselves are not fully ported. 32. Zope2 Framework Official website: https://www.php.cn/link/6dcb94fb55921f2416219b454651bffc ##Advantages: Zope 2 is a The Python-based web application framework is the ancestor of all Python web applications and tools and a powerful branch of the Python family. Zope 2's "object publishing" system is ideal for object-oriented development methods and can reduce the developer's learning curve and help you discover some bad features in your application. Disadvantages: Zope is not suitable for simple RESTful APIs (per Bottle or Flask), or even for interactive ones For a basic website (à la Django), due to Zope's size and complexity, installation requires some work; it's not a matter of simply unzipping the sources into a project subfolder. 33. Web2py framework Official website: https ://www.php.cn/link/60bb8062ea8e0c7ff17bb2e484cd223a Advantages: Web2py is a free and open source web framework written in Python language and designed for agile Rapidly develop web applications with fast, scalable, secure and portable database-driven applications, following the LGPLv3 open source license. Web2py provides a one-stop solution. The entire development process can be carried out on the browser. It provides the functions of online development of the Web version, HTML template writing, static file uploading, and database writing. Others include logging functionality and an automated admin interface. Disadvantages: One important limitation of Web2py is that it is only compatible with Python 2.x. First, this means that Web2py cannot use Python 3’s asynchronous syntax. If you rely on external libraries that are unique to Python 3, you're out of luck. However, work is underway to make Web2py Python 3 compatible, and it is nearing completion at the time of writing. 34. Pylons Framework Official website: https://www.php.cn/link/ddc96fb7d590861ce4bbc4579f5fa848 ##Advantages: Pylons are An open source web application framework written in python. It extends the WSGI standard, improves reusability and separates functionality into independent modules. Pylons is typical of the latest web application frameworks, similar to Django and TurboGears. Pylons is heavily influenced by Ruby on Rails: two of its components, Routes and WebHelpers, are Python implementations of Rails features. Cons: Pylons has been merged with repoze.bfg and is now in maintenance-only mode. It is highly recommended that new projects start with the newly merged web framework pyramid. 35. Cubes Framework Official website: https://www.php.cn/link/9fb2c3bda2393ae337242f405c93a010 ## Pros: Cubes is a lightweight Python framework and toolset for developing reporting and analytical applications, online analytical processing (OLAP), multidimensional analysis, and exploring aggregated data. It is part of Data Brewery. Disadvantages: The implicit aggregate record_count is no longer provided for each cube. It must be clearly defined as an aggregate: the old backend architecture has limitations. It only allows the use of a store, the model must be known before the server is started, it is not possible to obtain the model from a remote source. 36. Dpark framework https ://www.php.cn/link/e7a561a2f218bf9cc0e697598320ec59 Advantages: DPark is a Python clone version of Spark, a Python The implemented distributed computing framework can easily implement large-scale data processing and low-latency iterative calculations. This computing framework is similar to MapReduce, but is more flexible, can easily perform distributed computing using Python, and provides more functions for better iterative computing. DPark is developed, implemented and maintained by the domestic Douban Company. According to Douban Company's description, most of the data analysis within Douban Company is currently completed using DPark, and the entire project is also becoming perfect. Disadvantages: Dpark uses a process. In Python, due to the existence of GIL (Global Interpreter Lock), even on multi-core machines Using multiple threads, there is no way to truly achieve concurrent execution between these threads. 37. Buildbot Framework https ://www.php.cn/link/9b1fc5df81cadf52164c02bf92678f95 Advantages: Buildbot is an open source continuous build and continuous delivery implemented in python Tools used by well-known projects such as Python, Mozilla, Chromium, WebKit, etc. Buildbot can directly use python packages, easily own tens of thousands of libraries, and has strong expansion capabilities. If you feel that Jenkins already meets your needs easily, you don't need Buildbot. If you find it inefficient and difficult to expand in Jenkins, and some actions that can be achieved with scripts such as python are difficult to implement in Jenkins, then you can take a look at Buildbot. Disadvantages: buildbot does not support multi-projects well.
The above is the detailed content of Summary of 37 Python Web Development Frameworks. For more information, please follow other related articles on the PHP Chinese website!