gunicorn+flask使用与配置
gun.conf的内容
import os
bind = '10.1.240.222:5000'
workers = 4
backlog = 2048
worker_class = "sync"
debug = True
proc_name = 'gunicorn.proc'
pidfile = '/tmp/gunicorn.pid'
logfile = '/var/log/gunicorn/debug.log'
loglevel = 'debug'
tests.py 的内容
rom flask import Flask
from flask import render_template_string
import os
from werkzeug.contrib.fixers import ProxyFix
app = Flask(__name__)
@app.route('/')
def index():
return "worked!"
app.wsgi_app = ProxyFix(app.wsgi_app)
if __name__ == '__main__':
app.run()
注意要在nginx.conf中配置一个反向代理,监听5000端口,内容如下:
# For more information on configuration, see:
# * Official English Documentation: http://nginx.org/en/docs/
# * Official Russian Documentation: http://nginx.org/ru/docs/ user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid; events {
worker_connections 1024;
} http {
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"'; access_log /var/log/nginx/access.log main; sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048; include /etc/nginx/mime.types;
default_type application/octet-stream; # Load modular configuration files from the /etc/nginx/conf.d directory.
# See http://nginx.org/en/docs/ngx_core_module.html#include
# for more information.
include /etc/nginx/conf.d/*.conf; server {
listen 80 default_server;
listen [::]:80 default_server;
server_name _;
root /usr/share/nginx/html; # Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf; location / {
} error_page 404 /404.html;
location = /40x.html {
} error_page 500 502 503 504 /50x.html;
location = /50x.html {
} }
server {
listen 8080;
server_name hello.itu24.com; root /home/slqt/桌面; access_log /home/slqt/桌面/logs/access.log;
error_log /home/slqt/桌面/logs/error.log; location / {
proxy_set_header X-Forward-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
if (!-f $request_filename) {
proxy_pass http://127.0.0.1:5000;
break;
}
}
} }
启动脚本:gunicorn -c gun.conf run_test:app
gunicorn+flask使用与配置的更多相关文章
- gunicorn flask nginx环境配置
防火墙端口设置****修改后要重启生效(有时在控制面板中设置80端口无法生效) /etc/init.d/iptables statusservice iptables stopfirewall-cmd ...
- nginx+supervisor+gunicorn+flask
一. 更新系统 #yum -y install epel-release #yum clean all && yum makecache #yum -y update 二.安装pyth ...
- Flask:文件配置方式实践及其中的各种问题记录
Windows 10家庭中文版,Python 3.6.4,Flask 1.0.2, 提示: 1.请查看本文后面的“18-07-17 11:18重大纠正” ! 2.flask run命令运行时传入参数 ...
- 一寸宕机一寸血,十万容器十万兵|Win10/Mac系统下基于Kubernetes(k8s)搭建Gunicorn+Flask高可用Web集群
原文转载自「刘悦的技术博客」https://v3u.cn/a_id_185 2021年,君不言容器技术则已,欲言容器则必称Docker,毫无疑问,它是当今最流行的容器技术之一,但是当我们面对海量的镜像 ...
- 利用DockerHub在Centos7.7环境下部署Nginx反向代理Gunicorn+Flask独立架构
原文转载自「刘悦的技术博客」https://v3u.cn/a_id_165 上一篇文章:Docker在手,天下我有,在Win10系统下利用Docker部署Gunicorn+Flask打造独立镜像,是在 ...
- Python flask中的配置
当你开始学习Flask时,配置看上去是小菜一碟.你仅仅需要在config.py定义几个变量,然后万事大吉. 然而当你不得不管理一个生产上的应用的配置时,这一切将变得棘手万分. 你不得不设法保护API密 ...
- Flask之项目配置,目录构建,闪现
综合案例:学生成绩管理 新建项目目录students,并创建虚拟环境 mkvirtualenv students 安装开发中使用的依赖模块 pip install flask==0.12.4pip i ...
- Flask - app的配置和实例化Flask的参数
目录 Flask - app的配置和实例化Flask的参数 app的配置 app的配置 Flask - app的配置和实例化Flask的参数 app的配置 基本用法: from flask impor ...
- Flask 路由,配置,蓝图
路由 # -*- coding: utf-8 -*- from flask import Flask, url_for app = Flask(__name__) ...
随机推荐
- Spring Cloud(四) --- config
Spring Cloud Config 随着线上项目变的日益庞大,每个项目都散落着各种配置文件,如果采用分布式的开发模式,需要的配置文件随着服务增加而不断增多.某一个基础服务信息变更,都会引起一系列的 ...
- 前端学习 -- Html&Css -- 框架集
框架集和内联框架的作用类似,都是用于在一个页面中引入其他的外部的页面,框架集可以同时引入多个页面,而内联框架只能引入一个,在h5标准中,推荐使用框架集,而不使用内联框架. 使用frameset来创建一 ...
- TextView 借助Linkify,使用自定义模式设置链接
http://my.oschina.net/fengheju/blog/176105 TextView是android中的一个比较常用的控件,它有一个非常有趣的特性,可以通过android:autoL ...
- Flash:使用FileReference上传在Firefox上遇到的问题终于解决了
以前使用的是这样的一句话:var uploadURL:URLRequest = new URLRequest();uploadURL.url = "upload.asp"; 测试发 ...
- eclipse如何以指定JDK启动
eclipse如何以指定JDK启动 2018年01月11日 14:30:23 buerc 阅读数:11179 版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.csd ...
- STM8S ------ VCAP download
There is a specific pin called vcap in stm8s mcu. I recommend this pin connects to a 1uF capacitor w ...
- 紧急通知:Onion勒索病毒正在大范围传播!已有大量学生中招!(转)
在5月12日晚上20点左右,全国各地的高校学生纷纷反映,自己的电脑遭到病毒的攻击,文档被加密,壁纸遭到篡改,并且在桌面上出现窗口,强制学生支付等价300美元的比特币到攻击者账户上.我们的一位成员和其多 ...
- 5个强大的Java分布式缓存框架
在开发中大型Java软件项目时,很多Java架构师都会遇到数据库读写瓶颈,如果你在系统架构时并没有将缓存策略考虑进去,或者并没有选择更优的缓存策略,那么到时候重构起来将会是一个噩梦.本文主要是分享了5 ...
- 错误提示 nginx: [emerg] unknown directive "gzip_static"
1.检查nginx配置文件错误提示如下: [root@server nginx]# /applications/nginx/sbin/nginx -t -c /applications/nginx/n ...
- centos7.5 python修复
参考文章地址: 1.CentOS7修复python拯救yum: http://blog.51cto.com/welcomeweb/2132654 所有rpm包下载完成 wget http://mirr ...