<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                ### 導航 - [索引](# "總目錄") - [下一頁](# "uWSGI") | - [上一頁](# "mod_wsgi (Apache)") | - [Flask 0.10.1 文檔](#) ? - [部署選擇](#) ? # 獨立 WSGI 容器 有用 Python 編寫的流行服務器來容納 WSGI 應用并提供 HTTP 服務。這些服務器在運行時是獨立的:你可以從你的 web 服務器設置到它的代理。如果你遇見問題,請注意[*代理設置*](#) 一節的內容。 ### Gunicorn [Gunicorn](http://gunicorn.org/) [http://gunicorn.org/] ‘Green Unicorn' 是一個給 UNIX 用的 WSGI HTTP 服務器。這是一個從Ruby 的 Unicorn 項目移植的 pre-fork worker 模式。它既支持 [eventlet](http://eventlet.net/) [http://eventlet.net/] ,也支持 [greenlet](http://codespeak.net/py/0.9.2/greenlet.html) [http://codespeak.net/py/0.9.2/greenlet.html] 。在這個服務器上運行 Flask 應用是相當簡單的: ~~~ gunicorn myproject:app ~~~ [Gunicorn](http://gunicorn.org/) [http://gunicorn.org/] 提供了許多命令行選項 —— 見 gunicorn-h 。例如,用四個 worker 進程( gunicorn-h )來運行一個 Flask 應用,綁定到 localhost 的4000 端口( -b127.0.0.1:4000 ): ~~~ gunicorn -w 4 -b 127.0.0.1:4000 myproject:app ~~~ ### Tornado [Tornado](http://www.tornadoweb.org/) [http://www.tornadoweb.org/] 是一個開源的可伸縮的、非阻塞式的 web 服務器和工具集,它驅動了[FriendFeed](http://friendfeed.com/) [http://friendfeed.com/] 。因為它使用了 epoll 模型且是非阻塞的,它可以處理數以千計的并發固定連接,這意味著它對實時 web 服務是理想的。把 Flask 集成這個服務是直截了當的: ~~~ from tornado.wsgi import WSGIContainer from tornado.httpserver import HTTPServer from tornado.ioloop import IOLoop from yourapplication import app http_server = HTTPServer(WSGIContainer(app)) http_server.listen(5000) IOLoop.instance().start() ~~~ ### Gevent [Gevent](http://www.gevent.org/) [http://www.gevent.org/] 是一個基于協同程序的 Python 網絡庫,使用 [greenlet](http://codespeak.net/py/0.9.2/greenlet.html) [http://codespeak.net/py/0.9.2/greenlet.html] 來在[libevent](http://monkey.org/~provos/libevent/) [http://monkey.org/~provos/libevent/] 的事件循環上提供高層的同步 API ~~~ from gevent.wsgi import WSGIServer from yourapplication import app http_server = WSGIServer(('', 5000), app) http_server.serve_forever() ~~~ ### 代理設置 如果你在一個 HTTP 代理后把你的應用部署到這些服務器中的之一,你需要重寫一些標頭來讓應用正常工作。在 WSGI 環境中兩個有問題的值通常是 REMOTE_ADDR 和HTTP_HOST 。你可以配置你的 httpd 來傳遞這些標頭,或者在中間件中手動修正。Werkzeug 帶有一個修正工具來解決常見的配置,但是你可能想要為特定的安裝自己寫WSGI 中間件。 這是一個簡單的 nginx 配置,它監聽 localhost 的 8000 端口,并提供到一個應用的代理,設置了合適的標頭: ~~~ server { listen 80; server_name _; access_log /var/log/nginx/access.log; error_log /var/log/nginx/error.log; location / { proxy_pass http://127.0.0.1:8000/; proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } } ~~~ 如果你的 httpd 不提供這些標頭,最常見的配置引用從 X-Forwarded-Host 設置的主機名和從 X-Forwarded-For 設置的遠程地址: ~~~ from werkzeug.contrib.fixers import ProxyFix app.wsgi_app = ProxyFix(app.wsgi_app) ~~~ 信任標頭 請記住在一個非代理配置中使用這樣一個中間件會是一個安全問題,因為它盲目地信任一個可能由惡意客戶端偽造的標頭。 如果你想從另一個標頭重寫標頭,你可能會使用這樣的一個修正程序: ~~~ class CustomProxyFix(object): def __init__(self, app): self.app = app def __call__(self, environ, start_response): host = environ.get('HTTP_X_FHOST', '') if host: environ['HTTP_HOST'] = host return self.app(environ, start_response) app.wsgi_app = CustomProxyFix(app.wsgi_app) ~~~ ? 版權所有 2013, Armin Ronacher.
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看