# Information_flask
**Repository Path**: potato233/Information_flask
## Basic Information
- **Project Name**: Information_flask
- **Description**: 简直了~脑壳疼
- **Primary Language**: Python
- **License**: Not specified
- **Default Branch**: master
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 1
- **Forks**: 0
- **Created**: 2018-06-27
- **Last Updated**: 2021-11-02
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
# Information_flask
#### 项目介绍
flask项目练习
#### 软件架构
flask
#### 使用说明
1. 在虚拟环境安装所需的扩展
pip install -r requirements.txt
2. 在本地运行
workon安装扩展的虚拟环境,进入项目根目录
Python manage.py runserver
3. 在服务器端运行
服务器开放5000端口
安装 Nginx
$ sudo apt-get install nginx
编辑配置文件
sudo vim /etc/nginx/sites-available/default
复制以下代码
```
upstream flask {
server 127.0.0.1:5000;
server 127.0.0.1:5001;
}
server {
# 监听80端口
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/html;
index index.html index.htm index.nginx-debian.html;
server_name _;
location / {
# 请求转发到gunicorn服务器
proxy_pass http://127.0.0.1:5000;
# 请求转发到多个gunicorn服务器
# proxy_pass http://flask;
# 设置请求头,并将头信息传递给服务器端
proxy_set_header Host $host;
# 设置请求头,传递原始请求ip给 gunicorn 服务器
proxy_set_header X-Real-IP $remote_addr;
}
}
```
启动 Nginx
/etc/init.d/nginx start
运行程序
-w: 表示进程(worker) -b:表示绑定ip地址和端口号(bind)
gunicorn -w 2 -b 127.0.0.1:5000 运行文件名称:Flask程序实例名
gunicorn -w 2 -b 127.0.0.1:5000 manage:app
#### 参与贡献
:stuck_out_tongue_closed_eyes: