uWSGI有什么意义? [英] What is the point of uWSGI?

查看:136
本文介绍了uWSGI有什么意义?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在查看 WSGI规范,我试图弄清楚服务器像 uWSGI 适合图片。我明白WSGI规范的意义在于将网络服务器(如nginx)与Web应用程序(如使用 Flask 。我不明白的是uWSGI的。为什么不能直接调用我的Flask应用程序? WSGI不能直接向它说话吗?为什么uWSGI需要进入它们之间?

I'm looking at the WSGI specification and I'm trying to figure out how servers like uWSGI fit into the picture. I understand the point of the WSGI spec is to separate web servers like nginx from web applications like something you'd write using Flask. What I don't understand is what uWSGI is for. Why can't nginx directly call my Flask application? Can't flask speak WSGI directly to it? Why does uWSGI need to get in between them?

WSGI规范有两个方面:服务器和Web应用程序。哪一边是uWSGI?

There are two sides in the WSGI spec: the server and the web app. Which side is uWSGI on?

推荐答案

好吧,我想我现在得到这个。我在维基百科artile 中阅读以下说明:

Okay, I think I get this now. I read the following description in a Wikipedia artile:


在服务器和应用程序之间,可能有一个WSGI
中间件,它实现了API的两端。服务器
接收来自客户端的请求,并将其转发给中间件。
处理完成后,它向应用程序发送一个请求。
应用程序的响应由中间件转发到服务器
,最终转发给客户端。

Between the server and the application, there may be a WSGI middleware, which implements both sides of the API. The server receives a request from a client and forwards it to the middleware. After processing, it sends a request to the application. The application's response is forwarded by the middleware to the server and ultimately to the client.

没有具体说,但我猜测,uWSGI是这些中间件之一。我的理解是,uWSGI充当Flask应用程序的适配器,因此Flask(或者任何其他您想使用的框架)不必具体了解如何实现WSGI规范的应用程序端。

It doesn't specifically say, but I'm guessing that uWSGI is one of these middlewares. My understanding is that uWSGI acts as an adapter around your Flask app so that Flask (or any other framework you want to use) doesn't have to know specifically how to implement the app side of the WSGI specification.

所以要回答我自己的问题,uWSGI和Flask一起构成了WSGI的应用程序端,而nginx则是Web服务器端。

So to answer my own question, uWSGI and Flask together form the app side of WSGI and nginx is the web server side.

I相信你也可以让uWSGI作为网络服务器运行,在这种情况下,它可以扮演两种角色,但我怀疑大多数人会这样做。

I believe you can also have uWSGI run as the web server in which case it would play both roles, but I doubt most people would do it that way.

对于任何有兴趣的,我写了一篇博客文章关于它的更多细节,一些历史和一些例子。

For anyone who is interested, I wrote a blog article about it with more specifics, a bit of history, and some examples.

这篇关于uWSGI有什么意义?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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