├── .gitignore ├── .idea ├── dataSources.local.xml ├── dataSources.xml ├── dataSources │ ├── a1551de7-13e6-470e-b51f-5bf906092fa5.xml │ └── a1551de7-13e6-470e-b51f-5bf906092fa5 │ │ └── storage_v2 │ │ └── _src_ │ │ └── schema │ │ ├── sys.zb4BAA.meta │ │ └── sys.zb4BAA.zip ├── falsk_app.iml ├── misc.xml ├── modules.xml ├── vcs.xml └── workspace.xml ├── 01_flask_route.py ├── 02_flask_request对象.py ├── 03_flask_templates.py ├── 04_flask_table.py ├── 05_flask_return_json.py ├── 06_flask_table_submit_to_mysql.py ├── 07_flask_echarts_1.py ├── 07_flask_echarts_2.py ├── 07_flask_echarts_3.py ├── 08_flask_pyecharts.py ├── 09_flask_pyecharts_mysql.py ├── 10_flask_file_downloads.py ├── 11_flask_navicat.py ├── LICENSE ├── Python Flask Web服务精简教程.pdf ├── app.py ├── app2.py ├── app_demo.py ├── app_flask_echarts.py ├── data └── pvuv.txt ├── db.py ├── flask_model_settle_demo ├── data │ ├── test.csv │ └── training.csv ├── flask_api │ ├── Flask_Echo.py │ ├── Flask_Model_Settle.py │ ├── Flask_Model_Trainning.py │ ├── __init__.py │ ├── flask_api.yml │ ├── hello-world.py │ ├── models │ │ ├── model_v1.pk │ │ └── model_v2.pk │ ├── requirements.txt │ ├── server.py │ ├── server_test.py │ └── utils.py └── notebooks │ ├── ML Models as APIs using Flask.ipynb │ └── images │ ├── flaskapp1.png │ ├── flaskapp2.png │ └── flaskapp3.png ├── import_sql.py ├── static ├── 1.jpg ├── 2.jpg ├── china.js ├── echarts.min.js ├── jquery-3.4.1.min.js └── test_form.html ├── templates ├── echarts.html ├── echarts2.html ├── echarts3.html ├── hello.html ├── index.html ├── map.html ├── nav.html ├── nav_vis.html ├── pvuv.html ├── show_add_user.html ├── show_echarts_1.html ├── show_echarts_2.html ├── show_echarts_3.html ├── show_mypyecharts.html ├── show_pyecharts.html ├── show_user.html ├── show_users.html ├── use_template.html └── welcome_here.html ├── test_get_json.py └── 怎样在线上生产环境使用uwsgi部署Python的Flask服务 ├── img ├── 1.jpg ├── 10.jpg ├── 11.jpg ├── 12.jpg ├── 13.jpg ├── 14.jpg ├── 15.jpg ├── 16.jpg ├── 17.jpg ├── 2.jpg ├── 3.jpg ├── 4.jpg ├── 5.jpg ├── 6.jpg ├── 7.jpg ├── 8.jpg └── 9.jpg └── read.md /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | pip-wheel-metadata/ 24 | share/python-wheels/ 25 | *.egg-info/ 26 | .installed.cfg 27 | *.egg 28 | MANIFEST 29 | 30 | # PyInstaller 31 | # Usually these files are written by a python script from a template 32 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 33 | *.manifest 34 | *.spec 35 | 36 | # Installer logs 37 | pip-log.txt 38 | pip-delete-this-directory.txt 39 | 40 | # Unit test / coverage reports 41 | htmlcov/ 42 | .tox/ 43 | .nox/ 44 | .coverage 45 | .coverage.* 46 | .cache 47 | nosetests.xml 48 | coverage.xml 49 | *.cover 50 | *.py,cover 51 | .hypothesis/ 52 | .pytest_cache/ 53 | 54 | # Translations 55 | *.mo 56 | *.pot 57 | 58 | # Django stuff: 59 | *.log 60 | local_settings.py 61 | db.sqlite3 62 | db.sqlite3-journal 63 | 64 | # Flask stuff: 65 | instance/ 66 | .webassets-cache 67 | 68 | # Scrapy stuff: 69 | .scrapy 70 | 71 | # Sphinx documentation 72 | docs/_build/ 73 | 74 | # PyBuilder 75 | target/ 76 | 77 | # Jupyter Notebook 78 | .ipynb_checkpoints 79 | 80 | # IPython 81 | profile_default/ 82 | ipython_config.py 83 | 84 | # pyenv 85 | .python-version 86 | 87 | # pipenv 88 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 89 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 90 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 91 | # install all needed dependencies. 92 | #Pipfile.lock 93 | 94 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow 95 | __pypackages__/ 96 | 97 | # Celery stuff 98 | celerybeat-schedule 99 | celerybeat.pid 100 | 101 | # SageMath parsed files 102 | *.sage.py 103 | 104 | # Environments 105 | .env 106 | .venv 107 | env/ 108 | venv/ 109 | ENV/ 110 | env.bak/ 111 | venv.bak/ 112 | 113 | # Spyder project settings 114 | .spyderproject 115 | .spyproject 116 | 117 | # Rope project settings 118 | .ropeproject 119 | 120 | # mkdocs documentation 121 | /site 122 | 123 | # mypy 124 | .mypy_cache/ 125 | .dmypy.json 126 | dmypy.json 127 | 128 | # Pyre type checker 129 | .pyre/ 130 | -------------------------------------------------------------------------------- /.idea/dataSources.local.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | #@ 7 | ` 8 | 9 | 10 | master_key 11 | root 12 | *:* 13 | 14 | 15 | -------------------------------------------------------------------------------- /.idea/dataSources.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | mysql.8 6 | true 7 | com.mysql.cj.jdbc.Driver 8 | jdbc:mysql://127.0.0.1:3306 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /.idea/dataSources/a1551de7-13e6-470e-b51f-5bf906092fa5/storage_v2/_src_/schema/sys.zb4BAA.meta: -------------------------------------------------------------------------------- 1 | #n:sys -------------------------------------------------------------------------------- /.idea/dataSources/a1551de7-13e6-470e-b51f-5bf906092fa5/storage_v2/_src_/schema/sys.zb4BAA.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/7125messi/Python-Flask-Web/12d782350317d07753a140022bafb2e00bdeace6/.idea/dataSources/a1551de7-13e6-470e-b51f-5bf906092fa5/storage_v2/_src_/schema/sys.zb4BAA.zip -------------------------------------------------------------------------------- /.idea/falsk_app.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 20 | 21 | 22 | 24 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/workspace.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 14 | 15 | 25 | 26 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /templates/echarts.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | ECharts 6 | 7 | 8 | 9 | 10 | {% include 'nav_vis.html' %} 11 | 12 |
13 |
14 |
15 |
16 |
17 | 18 | 425 | 426 | 427 | -------------------------------------------------------------------------------- /templates/echarts2.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | ECharts 6 | 7 | 8 | 9 | 10 | {% include 'nav_vis.html' %} 11 | 12 |
13 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /templates/echarts3.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | ECharts 6 | 7 | 8 | 9 | 10 | {% include 'nav_vis.html' %} 11 | 12 |
13 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /templates/hello.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Title 6 | 7 | 8 | {% include 'nav.html' %} 9 |

hello world!

10 |

{{ data }}

11 |
12 | 13 |
14 | 15 | 16 | -------------------------------------------------------------------------------- /templates/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | ECharts3 Ajax 6 | 7 | 8 | 9 | 10 | 11 |
12 | 146 | 147 | 148 | -------------------------------------------------------------------------------- /templates/map.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | ECharts3 Ajax 6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 62 | 63 | 64 | -------------------------------------------------------------------------------- /templates/nav.html: -------------------------------------------------------------------------------- 1 |
2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
欢迎echarts报表pyecharts报表自己的报表
10 |
11 | -------------------------------------------------------------------------------- /templates/nav_vis.html: -------------------------------------------------------------------------------- 1 |
2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
欢迎echarts报表echarts2报表echarts3报表
10 |
11 | -------------------------------------------------------------------------------- /templates/pvuv.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 网站的PVUV数据 6 | 7 | 8 |

9 | 网站的PVUV数据表格 10 |

11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 | {% for row in data %} 19 | 20 | 21 | 22 | 23 | 24 | {% endfor %} 25 |
日期PVUV
{{ row[0] }}{{ row[1] }}{{ row[2] }}
26 |
27 | 28 | 29 | -------------------------------------------------------------------------------- /templates/show_add_user.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 提交用户信息 6 | 7 | 8 |
9 |

提交用户信息:

10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 |
用户名
性别
年龄
邮箱
提交
33 |
34 |
35 | 36 | 37 | -------------------------------------------------------------------------------- /templates/show_echarts_1.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | ECharts 6 | 7 | 8 | 9 | 10 | 11 |
12 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /templates/show_echarts_2.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | ECharts 6 | 7 | 8 | 9 | 10 | 11 |
12 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /templates/show_echarts_3.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | ECharts 6 | 7 | 8 | 9 | 10 | {% include 'nav.html' %} 11 | 12 |
13 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /templates/show_mypyecharts.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | ECharts 6 | 7 | 8 | 9 | 10 | {% include 'nav.html' %} 11 | 12 |

饼图

13 |
14 |

柱状图

15 |
16 |

折现图

17 |
18 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /templates/show_pyecharts.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | ECharts 6 | 7 | 8 | 9 | 10 | {% include 'nav.html' %} 11 | 12 |
13 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /templates/show_user.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 查看单个用户信息 6 | 7 | 8 |

查看单个用户信息

9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 |
用户ID{{ user["id"] }}
姓名{{ user["name"] }}
性别{{ user["sex"] }}
年龄{{ user["age"] }}
邮箱{{ user["email"] }}
31 | 32 | 33 | -------------------------------------------------------------------------------- /templates/show_users.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 查看用户列表 6 | 7 | 8 |

查看用户列表

9 | 10 | 11 | 12 | 13 | 14 | 15 | {% for user in datas %} 16 | 17 | 18 | 19 | 24 | 25 | {% endfor %} 26 |
用户ID用户名称查看详情
{{ user["id"] }}{{ user["name"] }} 20 | 21 | 查看详情 22 | 23 |
27 | 28 | 29 | -------------------------------------------------------------------------------- /templates/use_template.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Title 6 | 7 | 8 |

9 | {{ title }} 10 |

11 | {% for data in datas %} 12 | {% if data[0] != 2 %} 13 |

14 | {{ data[0] }}:{{ data[1] }} 15 |

16 | {% endif %} 17 | {% endfor %} 18 | 19 | 20 | -------------------------------------------------------------------------------- /templates/welcome_here.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 首页 6 | 7 | 8 | {% include 'nav_vis.html' %} 9 |

{{ data }}

10 |
11 | 12 |
13 | 14 | 15 | -------------------------------------------------------------------------------- /test_get_json.py: -------------------------------------------------------------------------------- 1 | import requests 2 | import json 3 | 4 | url = "http://127.0.0.1:5000/getjson" 5 | r = requests.get(url) 6 | 7 | print(r.status_code) 8 | print(r.text) 9 | 10 | 11 | print(json.loads(r.text)) 12 | for row in json.loads(r.text): 13 | print(row) 14 | -------------------------------------------------------------------------------- /怎样在线上生产环境使用uwsgi部署Python的Flask服务/img/1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/7125messi/Python-Flask-Web/12d782350317d07753a140022bafb2e00bdeace6/怎样在线上生产环境使用uwsgi部署Python的Flask服务/img/1.jpg -------------------------------------------------------------------------------- /怎样在线上生产环境使用uwsgi部署Python的Flask服务/img/10.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/7125messi/Python-Flask-Web/12d782350317d07753a140022bafb2e00bdeace6/怎样在线上生产环境使用uwsgi部署Python的Flask服务/img/10.jpg -------------------------------------------------------------------------------- /怎样在线上生产环境使用uwsgi部署Python的Flask服务/img/11.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/7125messi/Python-Flask-Web/12d782350317d07753a140022bafb2e00bdeace6/怎样在线上生产环境使用uwsgi部署Python的Flask服务/img/11.jpg -------------------------------------------------------------------------------- /怎样在线上生产环境使用uwsgi部署Python的Flask服务/img/12.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/7125messi/Python-Flask-Web/12d782350317d07753a140022bafb2e00bdeace6/怎样在线上生产环境使用uwsgi部署Python的Flask服务/img/12.jpg -------------------------------------------------------------------------------- /怎样在线上生产环境使用uwsgi部署Python的Flask服务/img/13.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/7125messi/Python-Flask-Web/12d782350317d07753a140022bafb2e00bdeace6/怎样在线上生产环境使用uwsgi部署Python的Flask服务/img/13.jpg -------------------------------------------------------------------------------- /怎样在线上生产环境使用uwsgi部署Python的Flask服务/img/14.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/7125messi/Python-Flask-Web/12d782350317d07753a140022bafb2e00bdeace6/怎样在线上生产环境使用uwsgi部署Python的Flask服务/img/14.jpg -------------------------------------------------------------------------------- /怎样在线上生产环境使用uwsgi部署Python的Flask服务/img/15.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/7125messi/Python-Flask-Web/12d782350317d07753a140022bafb2e00bdeace6/怎样在线上生产环境使用uwsgi部署Python的Flask服务/img/15.jpg -------------------------------------------------------------------------------- /怎样在线上生产环境使用uwsgi部署Python的Flask服务/img/16.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/7125messi/Python-Flask-Web/12d782350317d07753a140022bafb2e00bdeace6/怎样在线上生产环境使用uwsgi部署Python的Flask服务/img/16.jpg -------------------------------------------------------------------------------- /怎样在线上生产环境使用uwsgi部署Python的Flask服务/img/17.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/7125messi/Python-Flask-Web/12d782350317d07753a140022bafb2e00bdeace6/怎样在线上生产环境使用uwsgi部署Python的Flask服务/img/17.jpg -------------------------------------------------------------------------------- /怎样在线上生产环境使用uwsgi部署Python的Flask服务/img/2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/7125messi/Python-Flask-Web/12d782350317d07753a140022bafb2e00bdeace6/怎样在线上生产环境使用uwsgi部署Python的Flask服务/img/2.jpg -------------------------------------------------------------------------------- /怎样在线上生产环境使用uwsgi部署Python的Flask服务/img/3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/7125messi/Python-Flask-Web/12d782350317d07753a140022bafb2e00bdeace6/怎样在线上生产环境使用uwsgi部署Python的Flask服务/img/3.jpg -------------------------------------------------------------------------------- /怎样在线上生产环境使用uwsgi部署Python的Flask服务/img/4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/7125messi/Python-Flask-Web/12d782350317d07753a140022bafb2e00bdeace6/怎样在线上生产环境使用uwsgi部署Python的Flask服务/img/4.jpg -------------------------------------------------------------------------------- /怎样在线上生产环境使用uwsgi部署Python的Flask服务/img/5.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/7125messi/Python-Flask-Web/12d782350317d07753a140022bafb2e00bdeace6/怎样在线上生产环境使用uwsgi部署Python的Flask服务/img/5.jpg -------------------------------------------------------------------------------- /怎样在线上生产环境使用uwsgi部署Python的Flask服务/img/6.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/7125messi/Python-Flask-Web/12d782350317d07753a140022bafb2e00bdeace6/怎样在线上生产环境使用uwsgi部署Python的Flask服务/img/6.jpg -------------------------------------------------------------------------------- /怎样在线上生产环境使用uwsgi部署Python的Flask服务/img/7.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/7125messi/Python-Flask-Web/12d782350317d07753a140022bafb2e00bdeace6/怎样在线上生产环境使用uwsgi部署Python的Flask服务/img/7.jpg -------------------------------------------------------------------------------- /怎样在线上生产环境使用uwsgi部署Python的Flask服务/img/8.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/7125messi/Python-Flask-Web/12d782350317d07753a140022bafb2e00bdeace6/怎样在线上生产环境使用uwsgi部署Python的Flask服务/img/8.jpg -------------------------------------------------------------------------------- /怎样在线上生产环境使用uwsgi部署Python的Flask服务/img/9.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/7125messi/Python-Flask-Web/12d782350317d07753a140022bafb2e00bdeace6/怎样在线上生产环境使用uwsgi部署Python的Flask服务/img/9.jpg -------------------------------------------------------------------------------- /怎样在线上生产环境使用uwsgi部署Python的Flask服务/read.md: -------------------------------------------------------------------------------- 1 | Flask是一个Python非常轻量级的Web开发框架,如果你开发了一个报表服务、对MySQL的增删改查、一个机器学习在线预测服务,用flask是很方便的部署方式。 2 | 3 | flask自身提供了方法可以启动一个简单的Web服务器用于开发调试,**然而这个服务器性能比较低,当需要在线部署的时候,一般使用uswgi进行部署。** 4 | 5 | **部署uswgi+flask的方法**有两种: 6 | 7 | * **1、uswgi+flask,在一个单机部署web服务,uswgi可以对外提供高并发的服务;** 8 | * **2、在多个uswgi+flask的单机服务前面再加一个ngnix服务器,这个服务器可以用于静态资源、负载均衡等作用。** 9 | 10 | ![](./img/1.jpg) 11 | 12 | https://zhuanlan.zhihu.com/p/68676316 13 | 14 | ![](./img/2.jpg) 15 | 16 | ![](./img/3.jpg) 17 | 18 | ![](./img/4.jpg) 19 | 20 | ![](./img/5.jpg) 21 | 22 | ![](./img/6.jpg) 23 | 24 | ![](./img/7.jpg) 25 | 26 | ![](./img/8.jpg) 27 | 28 | ![](./img/9.jpg) 29 | 30 | ![](./img/10.jpg) 31 | 32 | ![](./img/11.jpg) 33 | 34 | ![](./img/12.jpg) 35 | 36 | ![](./img/13.jpg) 37 | 38 | ![](./img/14.jpg) 39 | 40 | ![](./img/15.jpg) 41 | 42 | ![](./img/16.jpg) 43 | 44 | ![](./img/17.jpg) --------------------------------------------------------------------------------