python系列之Gunicorn

Gunicorn,源自Ruby的Unicorn项目,是一个Python WSGI HTTP服务器。它轻量级且易于使用,兼容多种Web框架。安装Gunicorn后,可以通过命令行查看选项,并直接启动应用。启动时,入口文件通常是包内__init__.py,而非main.py。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Gunicorn


Gunicorn(绿色独角兽)是一个Python WSGI的HTTP服务器。从Ruby的独角兽(Unicorn )项目移植。该Gunicorn服务器与各种Web框架兼容,实现非常简单,轻量级的资源消耗。Gunicorn直接用命令启动,不需要编写配置文件,相对uWSGI要容易很多。

安装gunicorn

pip install gunicorn

查看命令行选项: 安装gunicorn成功后,通过命令行的方式可以查看gunicorn的使用信息。

gunicorn -h
usage: gunicorn [OPTIONS] [APP_MODULE]

optional arguments:
  -h, --help            show this help message and exit
  -v, --version         show program's version number and exit
  --access-logfile FILE
                        The Access log file to write to. [None]
  --log-level LEVEL     The granularity of Error log outputs. [info]
  --capture-output      Redirect stdout/stderr to specified file in
                        :ref:`errorlog`. [False]
  --log-config FILE     The log config file to use. [None]
  --log-syslog-to SYSLOG_ADDR
                        Address to send syslog messages. [udp://localhost:514]
  --log-syslog-facility SYSLOG_FACILITY
                        Syslog facility name [user]
  --access-logformat STRING
                        The access log format. [%(h)s %(l)s %(u)s %(t)s
                        "%(r)s" %(s)s %(b)s "%(f)s" "%(a)s"]
  --cert-reqs CERT_REQS
                        Whether client certificate is required (see stdlib ssl
                        module's) [0]
  --check-config        Check the configuration. [False]
  --limit-request-line INT
                        The maximum size of HTTP request line in bytes. [4094]
  -k STRING, --worker-class STRING
                        The type of workers to use. [sync]
  --error-logfile FILE, --log-file FILE
                        The Error log file to write to. [-]
  --spew                Install a trace function that spews every line
                        executed by the server. [False]
  --certfile FILE       SSL certificate file [None]
  --paste-gl
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值