0.flask理想状况是部署在linux服务器上。事情总是有但是。。。
1.下载nginx(http://nginx.org/en/download.html)
2.打开conf文件夹,找到nginx.conf 找到,改一下端口号
3.cmd下运行 start nginx,访问8080即可
4.创建flask项目(https://dormousehole.readthedocs.io/en/latest/quickstart.html#id2)
4.1 创建目录如:flaskdemo
4.2 安装虚拟环境: py -m venv venv
4.3 运行虚拟环境: venvscriptsactivate
4.5 安装flask:pip install flask
5. 来一段flask小脚本,命名为:run.py (https://dormousehole.readthedocs.io/en/latest/quickstart.html#id2)
from flask import Flask app = Flask(__name__) @app.route('/') def hello_world(): return 'Hello, World!'
6.再来一段tornado小脚本,命名为server.py:(https://www.tornadoweb.org/en/stable/httpserver.html#http-server)
from tornado.wsgi import WSGIContainer from tornado.httpserver import HTTPServer from tornado.ioloop import IOLoop from run import app http_server = HTTPServer(WSGIContainer(app)) http_server.listen(5000) #flask默认的端口 print('run...') IOLoop.current().start()
7.尝试访问:127.0.0.1:5000 完成了
8.把这个地址让nginx代理一下,就行了.