{"id":20163840,"url":"https://github.com/systemlight/t-flask","last_synced_at":"2026-05-08T02:16:56.969Z","repository":{"id":125645568,"uuid":"343312171","full_name":"SystemLight/T-flask","owner":"SystemLight","description":":lock: :package: Flask framework back end development template.【基于Flask框架的后端开发模板】","archived":false,"fork":false,"pushed_at":"2022-05-31T07:59:52.000Z","size":2434,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-01-13T14:23:57.144Z","etag":null,"topics":["flask","python3","template"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SystemLight.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-03-01T06:24:17.000Z","updated_at":"2022-01-18T13:31:33.000Z","dependencies_parsed_at":null,"dependency_job_id":"248616a7-0b3e-4da8-9222-f8c89e9ff9a9","html_url":"https://github.com/SystemLight/T-flask","commit_stats":null,"previous_names":[],"tags_count":0,"template":true,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SystemLight%2FT-flask","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SystemLight%2FT-flask/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SystemLight%2FT-flask/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SystemLight%2FT-flask/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SystemLight","download_url":"https://codeload.github.com/SystemLight/T-flask/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241600492,"owners_count":19988715,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["flask","python3","template"],"created_at":"2024-11-14T00:32:01.627Z","updated_at":"2026-05-08T02:16:51.922Z","avatar_url":"https://github.com/SystemLight.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# T-flask\n\n\u003e Flask项目开发模板\n\n## 技术栈\n\n### 后端\n\n- [werkzeug](https://www.osgeo.cn/werkzeug/)\n- [flask](https://dormousehole.readthedocs.io/en/latest/index.html)\n- [gevent](https://www.gevent.org/contents.html)\n- [gevent-websocket](https://gitlab.com/noppo/gevent-websocket)\n- [webargs](https://webargs.readthedocs.io/en/latest/)\n- [pillow](https://pillow.readthedocs.io/en/stable/)\n- [captcha](https://github.com/lepture/captcha)\n- [python-dotenv](https://saurabh-kumar.com/python-dotenv/#getting-started)\n- [pymysql](https://pymysql.readthedocs.io/en/latest/modules/connections.html)\n- [sqlalchemy](https://docs.sqlalchemy.org/en/14/contents.html)\n- [alembic](https://alembic.sqlalchemy.org/en/latest/)\n- [sqlacodegen](https://github.com/agronholm/sqlacodegen)\n- [marshmallow](https://marshmallow.readthedocs.io/en/stable/)\n- [marshmallow-sqlalchemy](https://marshmallow-sqlalchemy.readthedocs.io/en/latest/index.html)\n- [flask-sqlalchemy](https://flask-sqlalchemy.palletsprojects.com/en/2.x/quickstart/)\n- [flask-sqlacodegen](https://github.com/ksindi/flask-sqlacodegen)\n- [flask-migrate](https://github.com/miguelgrinberg/Flask-Migrate)\n- [flask-marshmallow](https://flask-marshmallow.readthedocs.io/en/latest/index.html)\n- [flask-socketio](https://flask-socketio.readthedocs.io/en/latest/)\n\n### 前端\n\n- [jquery](https://jquery.cuishifeng.cn/)\n- [underscore](https://www.underscorejs.com.cn/)\n- [layui](https://www.layuiweb.com/doc/index.htm)\n- [notify](https://gitee.com/u33/notify)\n- [layui 第三方组件平台](https://layui.org.cn/fly/extend/index.html)\n- [socketio](https://socket.io/)\n\n## 用法\n\n1. T-flask默认使用 `pipenv` 作为包管理器，如果没有安装请执行下面命令\n\n```shell\npip install pipenv\n\n安装后添加环境变量\nPIPENV_VENV_IN_PROJECT = 1\nPIPENV_PYPI_MIRROR = https://mirrors.aliyun.com/pypi/simple/\n```\n\n2. 还原依赖环境\n\n```\npipenv install\n```\n\n3. T-flask默认使用阿里源仓库作为安装源\n\n```shell\n[[source]]\nurl = \"https://mirrors.aliyun.com/pypi/simple/\"\nverify_ssl = true\nname = \"aliyun\"\n```\n\n4. 部署nginx代理uwsgi配置\n\n- uwsgi管理\n\n```shell\n# 启动uWSGI服务器\nuwsgi --ini ./uwsgi.ini\n\n# 停止指定uwsgi\nuwsgi --stop uwsgi.pid\n\n# 停止所有uwsgi\npkill -f uwsgi -9\n \n# 查看所有uWSGI进程\nps aux | grep uwsgi\n\n# 重启uWSGI服务器\nservice uwsgi restart\n```\n\n- 宝塔面板：Python项目管理器配置uwsgi.ini\n\n```text\n[uwsgi]\nproject = t-flask\nsocket = 127.0.0.1:5000\nchmod-socket = 666\nuid = root\ngid = root\nchdir = /www/wwwroot/%(project).lisys.club/server\nlogto = ./info.log\nwsgi-file= ./wsgi.py\ncallable = app\nvacuum = True\nmaster = True\nprocesses = 1\nthreads = 100\nmax-requests = 5000\n```\n\n- uwsgi直接命令行启动运行\n\n```text\n[uwsgi]\nproject = t-flask\nsocket = 127.0.0.1:5000\nchmod-socket = 666\nuid = root\ngid = root\nchdir = .\nvenv = ./.venv\npidfile = ./uwsgi.pid\ndaemonize = ./%(project).log\nwsgi-file= ./wsgi.py\ncallable = app\nvacuum = True\nmaster = True\nprocesses = 1\nthreads = 100\nmax-requests = 5000\n```\n\n- uwsgi+gevent实现IO密集型异步并发处理\n\n```text\n[uwsgi]\nproject = t-flask\nsocket = 127.0.0.1:5000\nchmod-socket = 666\nuid = root\ngid = root\nchdir = /www/wwwroot/%(project)/server\nlogto = ./info.log\nwsgi-file = ./wsgi.py\ncallable = app\nvacuum = True\nmaster = True\nprocesses = 1\ngevent = 100\ngevent-monkey-patch = True\n```\n\n- uwsgi启动并且支持websocket访问\n\n```text\n[uwsgi]\nproject = t-flask\nhttp = 127.0.0.1:5555\nhttp-websockets = True\nuid = root\ngid = root\nchdir = .\nvenv = ./.venv\npidfile = ./uwsgi.pid\ndaemonize = ./%(project).log\nwsgi-file= ./wsgi.py\ncallable = app\nvacuum = True\nhttp-keepalive = True\nmaster = True\nprocesses = 1\ngevent = 100\nmax-requests = 1000\n```\n\n- 配置nginx代理：/etc/nginx/sites-enabled/default\n\n```text\n# 普通socket代理\nlocation / {\n    include uwsgi_params;\n    uwsgi_pass 127.0.0.1:5000;\n}\n\n# SSE支持\nlocation ^~ /api/file/subscribe/ {\n    include uwsgi_params;\n    uwsgi_pass 127.0.0.1:5001;\n    uwsgi_buffering off;\n}\n\n# websocket支持（版本要求1.4以上）\n# 反向代理可能会跨域，设置SocketIO跨域参数即可\n# uwsgi不要启用多进程\nlocation / {\n    proxy_pass http://127.0.0.1:5000;\n    proxy_cookie_domain domino_server nginx_server;\n    proxy_set_header Host $http_host;\n    proxy_set_header X-Real-IP $remote_addr;\n    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;\n    proxy_set_header X-Forwarded-Proto $scheme;\n}\n\nlocation /socket.io/ {\n    proxy_pass http://127.0.0.1:5000/socket.io/;\n    proxy_http_version 1.1;\n    proxy_set_header Host $host;\n    proxy_set_header Upgrade $http_upgrade;\n    proxy_set_header Connection \"upgrade\";\n    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;\n}\n```\n\n- Flask: SSE支持代码\n\n```python\ndef stream():\n    yield 'data: {}\\n\\n'\n\n\n@app.route('/message', methods=['GET'])\ndef message():\n    return Response(stream(), mimetype=\"text/event-stream\")\n```\n\n5. 数据库管理\n\n```shell\n# 数据库初始化\nflask initdb\n\n# 数据库迁移\nflask db init\nflask db migrate -m \"add note timestamp\"\nflask db upgrade\n\n# 数据库回滚\nflask db downgrade\n\n# 反向生成数据模型\nflask-sqlacodegen mysql+pymysql://root:password@127.0.0.1/db_name --outfile \"model.py\"  --flask\n```\n\n## License\n\nT-flask uses the MIT license, see LICENSE file for the details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsystemlight%2Ft-flask","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsystemlight%2Ft-flask","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsystemlight%2Ft-flask/lists"}