一:创建一个flask_one.py的文件
from flask import Flask app = Flask(__name__) @app.route("/flask_one") def index(): return "hello flask_one" if __name__ == "__main__": app.run(debug=True,port=10010)
python3 flask_one.py
[root@VM_0_13_centos flask_one]# python3 flaks_one.py * Serving Flask app "flaks_one" (lazy loading) * Environment: production WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead. * Debug mode: on * Running on http://127.0.0.1:10010/ (Press CTRL+C to quit) * Restarting with stat * Debugger is active! * Debugger PIN: 231-868-597
二:创建一个flask_two.py的文件
from flask import Flask app = Flask(__name__) @app.route("/flask_two") def index(): return "hello flask_two" if __name__ == "__main__": app.run(debug=True,port=10011)
python3 flask_two.py
[root@VM_0_13_centos flask_one]# python3 flaks_two.py * Serving Flask app "flaks_two" (lazy loading) * Environment: production WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead. * Debug mode: on * Running on http://127.0.0.1:10011/ (Press CTRL+C to quit) * Restarting with stat * Debugger is active! * Debugger PIN: 231-868-597
需求:外部只想暴露80接口,不想暴露10010和10011内部端口,通过www.xxxxx/flask_one和 www.xxxxx/flask_two即可以访问到这两个flask程序
# TODO