Thanks to visit codestin.com
Credit goes to github.com

Skip to content
forked from bangumi/server

hopefully the the next-generation backend server of bgm.tv

License

Notifications You must be signed in to change notification settings

littledgg/server

 
 

Repository files navigation

基于 python3.8 的新 api server

开发环境

python 版本: 3.8

使用poetry进行依赖管理。

git clone https://github.com/bangumi/server bangumi-server
cd bangumi-server

进入虚拟环境

python -m venv .venv # MUST use python 3.8
source .venv/bin/activate # enable virtualenv

安装依赖

poetry install --remove-untracked

安装 git hook

pre-commit install

设置

可设置的环境变量

  • MYSQL_HOST 默认 127.0.0.1
  • MYSQL_PORT 默认 3306
  • MYSQL_DB 默认 bangumi
  • MYSQL_USER 无默认值
  • MYSQL_PASS 无默认值

开发

项目结构

Web 框架 fastapi

ORM 类定义在 pol/db/tables.py 文件。

路由位于 pol/api 文件夹。

后端环境

https://github.com/bangumi/dev-env

启动开发服务器

uvicorn pol.server:app --reload --port 3000

测试

测试基于 pytest

运行测试(需要数据库)

pytest

编写测试

参照 tests/app/test_base_router.py 文件。在测试函数中添加client参数获取对应的 HTTP 测试客户端。client 是一个 requests.Session 的实例,可以使用 requests 的各种函数参数。

详细文档

代码风格

以 LF 为换行符

python

启用 pre-commit

pre-commit install

pre-commit 会在当前仓库安装一个 git hook,在每次 commit 前自动运行。

也可以手动运行

pre-commit run #only check changed files
pre-commit run --all-files # check all files

lint: flake8

配置文件

非 python 文件(yaml, json, markdown 等)使用 prettier 进行格式化。

pol

pol 来源于我的旧项目名,没有特殊含义。

License

BSD 3-Clause License

LICENSE

About

hopefully the the next-generation backend server of bgm.tv

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 99.5%
  • Dockerfile 0.5%