Flask + MySQL
- fork项目至本地目录并随时更新进度.
- 配置Python3.6环境, 推荐使用Miniconda. 配置教程
cd bupt-air-backend
# 安装依赖
pip install -r requirements.txt
# 测试数据库连接情况
python model.py
# 运行开发服务器
export FLASK_ENV=development
flask run
cd bupt-air-backend
# gunicorn
gunicorn --threads 16 app:app
# Nginx
server {
listen 80;
server_name example.org;
access_log /var/log/nginx/example.log;
location / {
proxy_pass http://127.0.0.1:8000;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
peewee is a small, expressive orm -- supports postgresql, mysql and sqlite
减少重复轮子
main_status = 1 # 表示主机状态,制冷1、制热2
is_standby = 1 # 记录是否待机,待机1、运行0
num = 3 # 每秒最多处理请求数目,默认为3条
n = 3 # 这一秒内还能接收n条请求
choice = 3 # 调度算法选择,随机1、先来先服务2、风速优先3
requestList = [] # 这一秒的请求列表
responseList = [] # 这一秒要处理的请求列表
run(self)
set_status(self, status) # 设置主机状态
set_number_request(self, number) # 设置每秒处理的请求数目
set_schedule(self, choice) # 设置调度类型