惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

W
WeLiveSecurity
T
The Exploit Database - CXSecurity.com
C
CXSECURITY Database RSS Feed - CXSecurity.com
S
Security @ Cisco Blogs
T
Threat Research - Cisco Blogs
TaoSecurity Blog
TaoSecurity Blog
Recent Commits to openclaw:main
Recent Commits to openclaw:main
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
腾讯CDC
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
T
The Blog of Author Tim Ferriss
Microsoft Azure Blog
Microsoft Azure Blog
罗磊的独立博客
F
Full Disclosure
博客园 - 【当耐特】
C
CERT Recently Published Vulnerability Notes
Engineering at Meta
Engineering at Meta
Application and Cybersecurity Blog
Application and Cybersecurity Blog
T
Threatpost
I
Intezer
V2EX - 技术
V2EX - 技术
H
Hackread – Cybersecurity News, Data Breaches, AI and More
The Hacker News
The Hacker News
小众软件
小众软件
Google DeepMind News
Google DeepMind News
T
Tailwind CSS Blog
D
Darknet – Hacking Tools, Hacker News & Cyber Security
B
Blog RSS Feed
Microsoft Security Blog
Microsoft Security Blog
N
News | PayPal Newsroom
MyScale Blog
MyScale Blog
AI
AI
Vercel News
Vercel News
Spread Privacy
Spread Privacy
美团技术团队
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
The GitHub Blog
The GitHub Blog
V
Vulnerabilities – Threatpost
Schneier on Security
Schneier on Security
Cyberwarzone
Cyberwarzone
G
GRAHAM CLULEY
Help Net Security
Help Net Security
Hacker News: Ask HN
Hacker News: Ask HN
Google DeepMind News
Google DeepMind News
MongoDB | Blog
MongoDB | Blog
L
LINUX DO - 热门话题
U
Unit 42
L
LangChain Blog
Recent Announcements
Recent Announcements

不明のNetWorkOS

Libmodsecurity 的安装与使用 使用 GitHub 部署密钥部署代码 Supervisor 的安装与使用 PHP 中的 JIT 配置 IOC 服务容器 在 Nginx 中为 PHP 添加环境变量 Git 基础命令 在 Laravel 中的 Vue 组件无法使用 @apply 的解决方案 [转载] 免费 VPS 大全
Python 使用 virtualenv 部署 flask 项目
不明 · 2021-09-14 · via 不明のNetWorkOS

环境

os: ubuntu20.04
python: python3.6


virtualenv

virtualenv 用来建立一个虚拟的 python 环境,一个专属于项目的 python 环境。

通过 pip 安装 virtualenv
python3.6 -m pip3 install virtualenv

创建一个独立的 Python 运行环境
python3.6 -m virtualenv venv

用 source 进入该环境
source venv/bin/activate

安装第三方包
python3.6 -m pip3 install -r requirements.txt


gunicorn

gunicorn 是一个 unix 上被广泛使用的高性能的 python wsgi unix http server

安装 gunicorn
python3.6 -m pip3 install gunicorn

gunicorn 启动 flask
gunicorn -w 4 -b 0.0.0.0:8000 main:app

参数解释:
-w INT,用于处理工作进程的数量,默认为 1
-b ADDRESS,ip 加端口,绑定运行的主机

以配置文件的方式启动

bind = '0.0.0.0:8000'
user = 'www'
workers = 2
threads = 4
worker_connections = 1000
backlog = 512
daemon = True
chdir = '/'
access_log_format = '%(t)s %(p)s %(h)s "%(r)s" %(s)s %(L)s %(b)s %(f)s" "%(a)s"'
loglevel = 'info'
worker_class = 'geventwebsocket.gunicorn.workers.GeventWebSocketWorker'
errorlog = chdir + '/logs/error.log'
accesslog = chdir + '/logs/access.log'
pidfile = chdir + '/logs/your.pid'

启动 gunicorn
gunicorn -c gunicorn.conf main:app