使用gunicorn部署python web
gunicorn 是一款支持wsgi的web服务器, 支持gevent
首先安装setuptools. wget https://bootstrap.pypa.io/ez_setup.py
$python ez_setup.py
$easy_install pip
$pip install gevent
$pip install gunicorn
$apt-get install libmysqld-dev
$pip install MySQL-python
安装完成后 既可以直接执行 gunicorn code:application code是的你代码文件。。 application是wsgifunc 默认使用的是8000端口
如flask:
core.py
from flask import Flask
app = Flask(__name__) @app.route('/')
def hello_world():
return 'Hello World!'
运行方法: gunicorn core:app
浏览器访问localhost:8000
可用的参数:
gunicorn -b 127.0.0.1:8080 core:app 绑定端口
gunicorn -w 8 core:app 开启多进程。
gunicorn -k gevent core:app 使用gevent模式
完成后, 配合nginx Supervisor(进程管理工具)即可搭建出健壮的服务器。
使用gunicorn部署python web的更多相关文章
- supervisor+gunicorn部署python web项目
有了Nginx,对于Tomcat没有必要详细了解. 有了supervisor,再也没有必要把一个程序设置成服务.驻留进程,supervisor真是一个相见恨晚的好工具. 在Tomcat中,所有的web ...
- nginx上部署python web
nginx上部署python web http://uwsgi-docs.readthedocs.io/en/latest/tutorials/Django_and_nginx.html
- nginx+gunicorn/uwsgi+python web 的前世今生
我们在部署 flask.django 等 python web 框架时,网上最多的教程就是 nginx+gunicorn/uwsgi 的部署方式,那为什么要这么部署呢,本文就来系统地解释这个问题. 必 ...
- nginx+uwsgi部署python web(web.py)
1.nginx: nginx 是一个 http 服务器,与 apache.lighttpd.Microsoft IIS 等属于同类产品. 2.uWSGI: uWSGI 是一个快速的.纯C语言开发的.自 ...
- 使用uwsgi 部署python web服务
uwsgi, wsgi协议的一个很好的实现,源码在这里:https://github.com/unbit/uwsgi c语言编写,有兴趣可以研究下. 上DEMO: wsgi_server.py def ...
- virtualenv 环境下 Nginx + Flask + Gunicorn+ Supervisor 搭建 Python Web
在这篇文章里,我们将搭建一个简单的 Web 应用,在虚拟环境中基于 Flask 框架,用 Gunicorn 做 wsgi 容器,用 Supervisor 管理进程,然后使用 Python 探针来监测应 ...
- 全面解读python web 程序的9种部署方式
转载自鲁塔弗的博客,本文地址http://lutaf.com/141.htm python有很多web 开发框架,代码写完了,部署上线是个大事,通常来说,web应用一般是三层结构 web serve ...
- [原]Python Web部署方式总结
不要让服务器裸奔 学过PHP的都了解,php的正式环境部署非常简单,改几个文件就OK,用FastCgi方式也是分分钟的事情.相比起来,Python在web应用上的部署就繁杂的多,主要是工具繁多,主流服 ...
- 如何使用Nginx和uWSGI或Gunicorn在Ubuntu上部署Flask Web应用
你好!欢迎阅读我的博文,你可以跳转到我的个人博客网站,会有更好的排版效果和功能. 此外,本篇博文为本人Pushy原创,如需转载请注明出处:https://pushy.site/posts/151981 ...
随机推荐
- XLA
原 TensorFlow技术内幕(七):模型优化之XLA(上) 2018年06月13日 14:53:49 jony0917 阅读数 5513 版权声明:本文为博主原创文章,遵循CC 4.0 by- ...
- 20190922 「HZOJ NOIP2019 Round #7」20190922模拟
综述 这次是USACO2019JAN Gold的题目. \(\mathrm{Cow Poetry}\) 题解 因为每句诗的长度一定是\(k\),所以自然而然想到背包. 设\(opt[i][j]\)代表 ...
- luoguP4294 [WC2008]游览计划
题意 斯坦纳树裸题. 显然答案是棵树. 设\(f[i][s]\)表示以\(i\)为根,集合为\(s\)的最小代价. 先在同根之间转移: \(f[i][s]=min(f[i][t]+f[i][s\ xo ...
- CF888G XOR-MST 最小异或生成树
CF888G XOR-MST 链接 CF888G 思路 trie上贪心,先左右两边连边,再用一条边的代价连起左右两颗树.因为内部的边一定比跨两棵树的边权笑,显然是对的. 代码自己瞎yy的.启发式合并 ...
- Python程序设计例题
例一:蒙特卡罗方法求解 π 值 from random import random from math import sqrt from time import clock DARTS=1000 hi ...
- [LeetCode] 915. Partition Array into Disjoint Intervals 分割数组为不相交的区间
Given an array A, partition it into two (contiguous) subarrays left and right so that: Every element ...
- [LeetCode] 663. Equal Tree Partition 划分等价树
Given a binary tree with n nodes, your task is to check if it's possible to partition the tree to tw ...
- C语言实现贪吃蛇游戏
#include<stdio.h> #include<stdlib.h> #include<string.h> #include<sys/times.h> ...
- 基于Django的Rest Framework框架的RESTful规范研究
一.什么是RESTful规范 总的来说:RESTful规范就是一个非技术,人为约定的一个面向资源的架构理念. REST与技术无关,代表的是一种软件架构风格,REST是Representational ...
- Visual Studio 2019 for Mac 离线更新方法
当你打开Visual Studio 2019 for Mac检查更新时,如果下载更新包很慢,可以尝试如下操作: 打开Finder(访达),找到~/Library/Caches/VisualStudio ...