← 返回命令列表

Linux command

waitress-serve 命令

文本

复制后可按需替换文件名、目录或参数。

常用示例

Serve a WSGI app on the default port 8080

waitress-serve [myapp:app]

Bind to a specific host and port

waitress-serve --host=[127.0.0.1] --port=[8080] [myapp:app]

Listen on multiple addresses

waitress-serve --listen=[127.0.0.1:8080] --listen=[127.0.0.1:8443] [myapp:app]

Use an application factory function

waitress-serve --call [myapp:create_app]

Listen on a Unix socket

waitress-serve --unix-socket=[/tmp/app.sock] [myapp:app]

Set number of worker threads

waitress-serve --threads=[8] [myapp:app]

Serve under a URL prefix (behind a reverse proxy)

waitress-serve --url-prefix=[/api] [myapp:app]

说明

waitress-serve is a production-quality WSGI server for Python web applications, implemented entirely in pure Python with no C extension dependencies. It serves frameworks like Flask, Django, and Pyramid and runs on any platform including Windows, Linux, and macOS. The server uses a multi-threaded architecture with a configurable number of worker threads to handle concurrent requests. It accepts connections on a TCP port or Unix socket and supports URL prefix configuration for applications mounted at sub-paths behind a reverse proxy. Waitress is designed to be simple and reliable for production deployments, requiring minimal configuration while providing solid performance. It is commonly used behind a reverse proxy like Nginx for static file serving and SSL termination.

参数

--host _ADDR_
Hostname or IP address to listen on. Default: `0.0.0.0`.
--port _PORT_
TCP port to listen on. Default: `8080`.
--listen _HOST:PORT_
Bind to a specific host:port pair. May be repeated for multiple listeners. Supports `*` as a wildcard host.
--threads _N_
Number of worker threads to handle requests. Default: `4`.
--unix-socket _PATH_
Path to a Unix domain socket (not available on Windows).
--unix-socket-perms _OCTAL_
Octal permissions for the Unix socket. Default: `600`.
--url-scheme _SCHEME_
Value for `wsgi.url_scheme`. Default: `http`.
--url-prefix _PREFIX_
Value for `SCRIPT_NAME` (for apps mounted at a sub-path). Default: empty.
--ident _STRING_
Server identity sent in the `Server` response header. Default: `waitress`.
--call
Treat the positional argument as a callable factory that returns the WSGI app, rather than using it directly as the app.
--connection-limit _N_
Maximum number of simultaneous connections. Default: `100`.
--channel-timeout _SECONDS_
Timeout for inactive connections. Default: `120`.
--trusted-proxy _IP_
IP address of a trusted reverse proxy that may supply forwarding headers.

FAQ

What is the waitress-serve command used for?

waitress-serve is a production-quality WSGI server for Python web applications, implemented entirely in pure Python with no C extension dependencies. It serves frameworks like Flask, Django, and Pyramid and runs on any platform including Windows, Linux, and macOS. The server uses a multi-threaded architecture with a configurable number of worker threads to handle concurrent requests. It accepts connections on a TCP port or Unix socket and supports URL prefix configuration for applications mounted at sub-paths behind a reverse proxy. Waitress is designed to be simple and reliable for production deployments, requiring minimal configuration while providing solid performance. It is commonly used behind a reverse proxy like Nginx for static file serving and SSL termination.

How do I run a basic waitress-serve example?

Run `waitress-serve [myapp:app]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does --host _ADDR_ do in waitress-serve?

Hostname or IP address to listen on. Default: `0.0.0.0`.