{"id":14065175,"url":"https://github.com/luolingchun/flask-api-demo","last_synced_at":"2025-10-08T07:06:50.014Z","repository":{"id":42864504,"uuid":"262798205","full_name":"luolingchun/flask-api-demo","owner":"luolingchun","description":"Flask REST API项目示例，包含JWT认证、RABC、rq异步任务、Swagger文档、Docker部署、uwsgi、supervisor……","archived":false,"fork":false,"pushed_at":"2025-07-05T01:14:19.000Z","size":982,"stargazers_count":32,"open_issues_count":0,"forks_count":7,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-07-05T02:44:40.770Z","etag":null,"topics":["flask","flask-api","flask-api-demo","flask-demo","flask-openapi3","jwt","rbac","rbac-authorization","rest","rest-api"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/luolingchun.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"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,"zenodo":null}},"created_at":"2020-05-10T13:54:30.000Z","updated_at":"2025-07-05T01:14:22.000Z","dependencies_parsed_at":"2023-01-20T04:33:59.285Z","dependency_job_id":"f91e78a2-36a2-49a8-8bbf-6354a558c1ed","html_url":"https://github.com/luolingchun/flask-api-demo","commit_stats":null,"previous_names":[],"tags_count":0,"template":true,"template_full_name":null,"purl":"pkg:github/luolingchun/flask-api-demo","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luolingchun%2Fflask-api-demo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luolingchun%2Fflask-api-demo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luolingchun%2Fflask-api-demo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luolingchun%2Fflask-api-demo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/luolingchun","download_url":"https://codeload.github.com/luolingchun/flask-api-demo/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luolingchun%2Fflask-api-demo/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278903051,"owners_count":26065791,"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","status":"online","status_checked_at":"2025-10-08T02:00:06.501Z","response_time":56,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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","flask-api","flask-api-demo","flask-demo","flask-openapi3","jwt","rbac","rbac-authorization","rest","rest-api"],"created_at":"2024-08-13T07:04:20.937Z","updated_at":"2025-10-08T07:06:49.971Z","avatar_url":"https://github.com/luolingchun.png","language":"Python","readme":"# flask-api-demo\n\n## 项目初始化\n\n执行`sh init.sh PROJECT_NAME`\n\n## 开发说明\n\n1. 修改`build.sh`和`docker-compose.yml`中镜像版本，执行`sh build.sh`构建镜像\n2. 执行`docker-compose up -d`启动容器\n3. 执行`docker exec -it flask-api-demo bash`进入容器\n4. 执行`supervisorctl stop webapp`停止服务，并执行`flask run`或`python wsgi.py`进入开发者模式\n5. 在`CHANGELOG.md`中记录版本日志，重新执行第一步发布镜像\n\n## 运维调试\n\n1. 进入容器后使用`supervisorctl status`进程状态\n\n   ```bash\n   # supervisorctl status\n   webapp                              RUNNING   pid 8, uptime 3 days, 5:35:50\n   worker                           RUNNING   pid 10, uptime 3 days, 5:35:50\n   ```\n   \n2. 停止进程：`supervisorctl stop webapp`\n3. 启动进程：`supervisorctl start webapp`\n4. 查看日志：`tail -f /data/log/webapp.log`\n5. 查看日志：`tail -f /data/log/worker.log`\n\n## 部署说明\n\n1. 创建`flask`网络：`docker network create flask`\n\n   可能遇到网络冲突问题，解决方法：\n   1. 删除网络：`docker network rm flask`\n   2. 创建网络时指定掩码和网关：\n   \n      `docker network create --subnet=192.168.0.0/24 --gateway=192.168.0.1 flask`\n\n2. 准备`docker-compose.yml`, 注释源码挂载：`- \"./:/work\"`\n\n3. 启动服务：`docker-compose up -d`\n\n4. 数据库迁移：\n\n    1. docker exec -it flask-api-demo bash\n    2. flask db init -d /data/data/migrations\n    3. flask db migrate -d /data/data/migrations\n    4. flask db upgrade -d /data/data/migrations\n\n5. 初始化数据库：\n\n   ```bash\n   flask init_db\n   ```\n\n## Docker配置文件\n\n1. vim /etc/docker/daemon.json\n   \n   - default-runtime：修改默认运行时为nvidia\n   - data-root：修改数据存储路径\n   - bip：修改网卡地址\n   \n   ```json\n   {\n       \"default-runtime\": \"nvidia\",\n       \"runtimes\": {\n           \"nvidia\": {\n               \"path\": \"nvidia-container-runtime\",\n               \"runtimeArgs\": []\n           }\n       },\n       \"data-root\":\"/data/docker_data\",\n       \"bip\":\"192.168.0.1/24\"\n   }\n   ```","funding_links":[],"categories":["Python"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluolingchun%2Fflask-api-demo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fluolingchun%2Fflask-api-demo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluolingchun%2Fflask-api-demo/lists"}