1+1=10

扬长避短 vs 取长补短

Python的Web开发框架

作为小白,只做个简单记录,不做评价。

Python中有大量的web开发框架,pyton官网的wiki中有一个详细列表。它将框架分为:流行(Popular)、其他(Other)和非活跃(Discontinued,Inactive)三种。流行的框架中又有全栈(Full stack)和非全栈(Non full stack)之分。

列表

官方认为流行的框架有(时间202312):

全栈(Full stack)

  • Django
  • Masonite
  • TurboGears
  • web2py

非全栈

  • aiohttp
  • Bottle
  • CherryPy
  • Falcon
  • FastAPI
  • Flask
  • Hug
  • Pyramid
  • Quart

除此之外,网络上有各种各样的排行榜,让人眼花缭乱。

不做比较

Django

  • https://www.djangoproject.com/
  • https://www.django-rest-framework.org/

Django /ˈdʒæŋɡoʊ/ is a full-stack web framework that includes everything you need to build a web application, from the database to the user interface.

Flask

  • https://flask.palletsprojects.com
  • https://flask-restful.readthedocs.io/en/latest/

Flask is a microframework, which means that it is a lightweight and flexible framework that does not include many features out of the box.

Flask depends on the Werkzeug WSGI toolkit, the Jinja template engine, and the Click CLI toolkit.

FastAPI

  • https://fastapi.tiangolo.com/

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

Hug

  • https://www.hug.rest/

Hug prioritizes simplicity and performance, making API development quick and

其他概念

wsgi vs asgi

  • WSGI:Python Web Server Gateway Interface。是一种专为python定义的接口规范,用于web服务端和web应用(框架)之间的连接。
  • ASGI:Asynchronous Server Gateway Interface。为Python Web服务、框架和应用之间提供一个标准的异步接口。它允许Web应用程序在处理请求时能够异步地执行其他任务。

Django 部署时支持 wsgi和asgi。FastAPI使用asgi。

wsgi

  • https://peps.python.org/pep-3333/
  • https://peps.python.org/pep-0333/

WSGI发音 “whiz-gee”(g发硬/g/) 或者 “whiskey”。

Apache(通过mod_wsgi)、Nginx(通过ngx_http_uwsgi_module) 和 Microsoft IIS(HttpPlatform) 都可以支持WSGI。

asgi

  • https://asgi.readthedocs.io/en/latest/

参考

  • https://wiki.python.org/moin/WebFrameworks
  • https://learn.microsoft.com/zh-cn/azure/developer/python/configure-python-web-app-local-environment
  • https://learn.microsoft.com/en-us/visualstudio/python/configure-web-apps-for-iis-windows
  • https://en.wikipedia.org/wiki/Web_Server_Gateway_Interface
  • http://nginx.org/en/docs/http/ngx_http_uwsgi_module.html
  • https://www.infoworld.com/article/3658336/asgi-explained-the-future-of-python-web-development.html

Python web

Comments