Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/luolingchun/flask-api-demo
Flask REST API项目示例,包含JWT认证、RABC、rq异步任务、Swagger文档、Docker部署、uwsgi、supervisor……
https://github.com/luolingchun/flask-api-demo
flask flask-api flask-api-demo flask-demo flask-openapi3 jwt rbac rbac-authorization rest rest-api
Last synced: 3 days ago
JSON representation
Flask REST API项目示例,包含JWT认证、RABC、rq异步任务、Swagger文档、Docker部署、uwsgi、supervisor……
- Host: GitHub
- URL: https://github.com/luolingchun/flask-api-demo
- Owner: luolingchun
- Created: 2020-05-10T13:54:30.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2024-07-21T02:12:52.000Z (4 months ago)
- Last Synced: 2024-08-13T07:08:21.267Z (3 months ago)
- Topics: flask, flask-api, flask-api-demo, flask-demo, flask-openapi3, jwt, rbac, rbac-authorization, rest, rest-api
- Language: Python
- Homepage:
- Size: 945 KB
- Stars: 23
- Watchers: 0
- Forks: 6
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
- jimsghstars - luolingchun/flask-api-demo - Flask REST API项目示例,包含JWT认证、RABC、rq异步任务、Swagger文档、Docker部署、uwsgi、supervisor…… (Python)
README
# flask-api-demo
## 项目初始化
执行`sh init.sh PROJECT_NAME`
## 开发说明
1. 修改`build.sh`和`docker-compose.yml`中镜像版本,执行`sh build.sh`构建镜像
2. 执行`docker-compose up -d`启动容器
3. 执行`docker exec -it flask-api-demo bash`进入容器
4. 执行`supervisorctl stop app`停止服务,并执行`flask run`或`python wsgi.py`进入开发者模式
5. 在`CHANGELOG.md`中记录版本日志,重新执行第一步发布镜像## 运维调试
1. 进入容器后使用`supervisorctl status`进程状态
```bash
# supervisorctl status
app RUNNING pid 8, uptime 3 days, 5:35:50
worker RUNNING pid 10, uptime 3 days, 5:35:50
```
2. 停止进程:`supervisorctl stop app`
3. 启动进程:`supervisorctl start app`
4. 查看日志:`tail -f /data/log/webapp.log`
5. 查看日志:`tail -f /data/log/worker.log`## 部署说明
1. 创建`flask`网络:`docker network create flask`
可能遇到网络冲突问题,解决方法:
1. 删除网络:`docker network rm flask`
2. 创建网络时指定掩码和网关:
`docker network create --subnet=192.168.0.0/24 --gateway=192.168.0.1 flask`2. 准备`docker-compose.yml`, 注释源码挂载:`- "./:/work"`
3. 启动服务:`docker-compose up -d`
4. 数据库迁移:
1. docker exec -it flask-api-demo bash
2. flask db init -d /data/data/migrations
3. flask db migrate -d /data/data/migrations
4. flask db upgrade -d /data/data/migrations5. 初始化数据库:
```bash
flask init_db
```## Docker配置文件
1. vim /etc/docker/daemon.json
- default-runtime:修改默认运行时为nvidia
- data-root:修改数据存储路径
- bip:修改网卡地址
```json
{
"default-runtime": "nvidia",
"runtimes": {
"nvidia": {
"path": "nvidia-container-runtime",
"runtimeArgs": []
}
},
"data-root":"/data/docker_data",
"bip":"192.168.0.1/24"
}
```