You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

88 lines
1.5 KiB

4 years ago
# coro-api
4 years ago
新型冠状病毒 实时数据 api
4 years ago
4 years ago
## API示例
### 获取全部
[https://api.yimian.xyz/coro](https://api.yimian.xyz/coro)
### 根据省份
[https://api.yimian.xyz/coro?province=山东](https://api.yimian.xyz/coro?province=山东)
### 根据城市
[https://api.yimian.xyz/coro?city=泰安](https://api.yimian.xyz/coro?city=泰安)
## 快速部署
4 years ago
### 环境要求
- `nodeJS`支持`express`任意版本
- `git`任意版本
### 下载文件
```
$ git clone https://github.com/iotcat/coro-api.git & cd coro-api
```
### 安装依赖
```shell
$ npm install
```
### 启动
```shell
$ node index.js
```
4 years ago
### 访问
4 years ago
```
http://localhost:17676
```
4 years ago
## 进阶
### GET参数
4 years ago
参数 | 描述 | 示例
:--: | :--: | :--:
province | 省份(国家) | 山东
city | 城市 | 泰安
### 修改端口
从`index.js`第9行修改默认端口。
4 years ago
### 禁止跨域
注释掉`index.js`第13行。
4 years ago
### 使用pm2守护进程
```shell
$ npm i -g pm2
$ pm2 start index.js --name coro-api -o /var/log/coro/api.out -e /var/log/coro/api.err --watch
```
### Nginx配置
将以下内容加入`server{}`中
```nginx
location / {
proxy_pass http://127.0.0.1:17676;
}
```
如果你不是从根目录映射,记得去`index.js`中第11行`app.get('/', f)`修改成你的路径。
### 爬虫配置
爬虫使用[coro-py](https://github.com/iotcat/coro-py), 请参考其文档。
## 开源协议
4 years ago
本项目使用MIT协议,允许非署名商业非商业使用。武汉加油!中国加油!!❤