Nginx, WSGI, Flask 간 의 관 계 를 어떻게 이해 합 니까?

3440 단어 webusgi
다음으로 이동:https://blog.csdn.net/lihao21/article/details/52304119
개술
       Nginx,WSGI(   uWSGI,uwsgi),Flask(   Django),            。        ,           。 
    ,         HTTP     Flask     ,      web    ,WSGI ,web   ,     。           ,           。
 1:web   ,web    WSGI      

웹 서버 계층
           -      ,         ,           ,            ,          。      ,       :

        
        
        

 Web            ,          HTTP        。   web          ,    web     Nginx,Apache,IIS 。   1      ,web             ,           。

웹 프레임 층
  Web               web    ,HTTP           web       。    web   Flask,Django ,    Flask      ,   web     :

 from flask import Flask
 app = Flask(__name__)

 @app.route('/hello')
 def hello_world():
    return 'Hello World!'

 if __name__ == '__main__':
     app.run(host='0.0.0.0', port=8080)

         ,       web       app。app        ip   8080   ,         。    ,HTTP      URL      ,          /hello       hello_world     ,hello_world    ‘Hello World!’    。   web        ,           HTTP   ,                             。Web             ,                。

WSGI 계층
  WSGI      ,           API,        ,WSGI       ,      Python   ,     Web Server Gateway Interface,    web     web         。    ,   web     web     WSGI  ,   web     web          。 
         web        web        。

  def application(env, start_response):
      start_response('200 OK', [('Content-Type', 'text/html')])
      return [b"Hello World"]

   application  web     ,  env,start_response   web        。  ,env     ,      HTTP_HOST,HOST_USER_AGENT,SERVER_PROTOCO      。start_response      ,         ,   status,response_headers。application        ,   http         Content-Type      ,          。

            WSGI   ,      WSGI   web             ,       application   。WSGI        env,start_response            ,    application      ,           。

      ,WSGI      ,           :

uwsgi
      wsgi         ,uWSGI         uwsgi   

uWSGI
    uwsgi   WSGI      web   。   uWSGI         web   ,              web    。

CGI
      ,     Python   ,    web                 。  ,               web   ,web            web  ,web                 ,  。 
       web       CGI  ,CGI  (   Python    )        ,     ,    。WSGI        CGI     。

   ,        WSGI   web     web      :WSGI       ,  web     web      。       ,Nginx      web   ,Flask     web  ,  ,WSGI   Nginx、Flask          。
    Nginx,WSGI,Flask          。 
**Nginx**:Hey,WSGI,         ,        ,   Flask       。 
**WSGI**:OK,Nginx。         ,          Flask  。 
**Flask**:Thanks WSGI!      ,             。 
**WSGI**:Alright,    。 
**Flask**:Okay,    ,          ,        Nginx。 
** WSGI**:Good job!Nginx,       ,             。 
** Nginx**:Cool,    ,            。      ~

    :
 http://hackerxu.com/2015/05/10/flask011.html
 https://www.quora.com/What-are-good-ways-to-understand-WSGI-flup-fastcgi-CGI-and-Django
 https://en.wikipedia.org/wiki/Web_Server_Gateway_Interface
 http://flask.pocoo.org/docs/0.10/quickstart/
 http://stackoverflow.com/questions/219110/how-python-web-frameworks-wsgi-and-cgi-fit-together
 https://www.python.org/dev/peps/pep-0333/
 《Python    ( 3 )》Wesley Chun 

좋은 웹페이지 즐겨찾기