Python web服務器
阿新 • • 發佈:2017-07-02
src http bre onf cat 技術分享 ons res sta
Python 配置wsgi接口
# 引入Python wsgi包 from wsgiref.simple_server import make_server # 撰寫服務器端程序代碼 def Application(envirn,start_response): start_response(‘200 ok‘,[(‘Content-Type‘,‘text/html‘)]) return ‘<b>hello world</b>‘ # 實例化一個監聽8080端口的服務器 server = make_server(‘‘,8080,Application) # 開始監聽http請求server.serve_forever()
wsgi是將Python服務器端程序鏈接到web服務器的通用協議
Nginx+uwsgi配置
安裝Nginx
brew install nginx
brew services start nginx
Nginx 配置文件
進入/usr/local/etc/nginx目錄下,執行 sudo vim nginx.conf
參考:http://www.cnblogs.com/Lxiaolong/p/4201973.html
安裝uwsgi及配置
pip install uwsgi
參考:http://www.cnblogs.com/sky20081816/p/3398864.html
Python web服務器