nginx下载地址 http://nginx.org/en/download.html
1,因windows对uwsgi支持不友好,flask自有服务不够强大,所以引用tornado服务
from tornado.wsgi import WSGIContainer from tornado.httpserver import HTTPServer from tornado.ioloop import IOLoop from run import app import sys,asyncio #python 3.8以上asyncio改变了循环方式 if sys.platform =='win32': asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy()) if __name__ == "__main__": http_server = HTTPServer(WSGIContainer(app)) http_server.listen(5000) print('start...') IOLoop.current().start()
2,下载解压好的nginx并添加环境变量,配置nginx.conf 实现反向代理
server { listen 80; server_name 127.0.0.1; charset utf-8; #charset koi8-r; #access_log logs/host.access.log main; location / { root html; index index.html index.htm; proxy_pass http://127.0.0.1:5000; } }
3,写个批处理一键启动项目及服务
@echo echo 正在启动服务 start python C:\p2p-master\server.py nginx.exe -s stop start nginx.exe REM 服务启动中...
效果如下:
标签:__,nginx,windows,server,tornado,import,start From: https://www.cnblogs.com/xcsg/p/17955874