独立的Python Web服务器和/或Nginx [英] Standalone Python web server and/or nginx

查看:98
本文介绍了独立的Python Web服务器和/或Nginx的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我已经阅读了一些有关Python Web框架(或服务器?)的文章,主要是 Tornado ,而且 FAPWS3 ,仍然有一些灰色区域.

So I've done some reading about Python web frameworks (or servers?), mostly Tornado and Bottle but also FAPWS3, and there are still some grey areas.

首先,据说这三个Web框架都非常快,但是它们都包含一个用Python编写的Web服务器(FAPWS3除外),该服务器应放在nginx/Apache之后.这不是在降低性能吗?我的意思是,我们知道Python比C慢得多,为什么不只使用nginx,或者更糟糕的是,仅使用附带的Python Web服务器?

First, these three web frameworks are all said to be fast, yet they all include a web server written in Python (except FAPWS3) which should be put behind nginx/Apache. Isn't this reducing the performance? I mean, we know that Python is much slower than C, why not only use nginx, or at worst, only the included Python web server?

推荐答案

首先,Tornado和FAPWS3是Web服务器,而Bottle是Web框架.这些属于完全不同的类别.

First of, Tornado and FAPWS3 are web servers, while Bottle is a web framework. Those belong to completely different categories.

Web框架通常作为HTTP("web")代理后面的 WSGI 服务器运行.大多数框架中包含的HTTP服务器仅用于快速开发和部署,以及在效率无关紧要的站点上轻松部署.

Web frameworks are usually run as a WSGI server behind a HTTP ("web") proxy. The HTTP server included in most frameworks is only there for fast development and deployment and easy deployment on sites where high efficiency doesn't matter.

基本上,这个想法是HTTP服务器(Apache/Lighttpd/Nginx/Tornado/FAPWS3等)非常擅长理解HTTP并从磁盘提供静态文件.另一方面,动态内容是由Python服务器使用Web框架(例如Bottle/Flask/web.py/Pylons/etc)生成的.然后,由Web框架生成的文档通过WSGI发送回HTTP服务器,放入HTTP响应并发送给客户端.

The idea is basically that the HTTP Server (Apache/Lighttpd/Nginx/Tornado/FAPWS3 etc) is very good at understanding HTTP and serving static files from the disk. The dynamic content on the other hand is generated by a Python server using a web framework like Bottle/Flask/web.py/Pylons/etc. The document produced by the web framework is then sent back to the HTTP server over WSGI, put in a HTTP Response and sent to the client.

这篇关于独立的Python Web服务器和/或Nginx的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆