Skip to content

Commit

Permalink
[*] 在config中加入 built_in_server_extra_params, 允许更多地控制flask内置服务器的参数
Browse files Browse the repository at this point in the history
  • Loading branch information
aploium committed Aug 10, 2016
1 parent 9b49958 commit 45bbabe
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
8 changes: 7 additions & 1 deletion config_default.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,13 +137,19 @@
enable_keep_alive_per_domain = False

# ############## Builtin server ##############
# v0.23.1+
# v0.23.1+ configs for flask builtin server (only affect when directly run wsgi.py)

# If you want to use the builtin server to listen Internet (NOT recommend)
# please modify the following configs
# set built_in_server_host='0.0.0.0' and built_in_server_debug=False
built_in_server_host = '127.0.0.1'
built_in_server_debug = True

# v0.23.2+ other params which will be passed to flask builtin server
# please see :func:`flask.app.Flask.fun`
# and :func:`werkzeug.serving.run_simple` for more information
# eg: {"processes":4, "hostname":"localhost"}
built_in_server_extra_params = {}

# ############## Cache Settings ##############
# Cache remote static files to your local storge. And access them directly from local storge if necessary.
Expand Down
9 changes: 7 additions & 2 deletions wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
__author__ = 'Aploium <i@z.codes>'

if __name__ == '__main__':
from zmirror import my_host_port, built_in_server_host, built_in_server_debug, warnprint
from zmirror import my_host_port, built_in_server_host, \
built_in_server_debug, built_in_server_debug, built_in_server_extra_params, warnprint

warnprint("You may directly running zmirror, which is NOT recommend for PRODUCTION environment.\n"
"Please deploy it using Apache,You can find a deploy tutorial here:\n"
Expand All @@ -22,7 +23,9 @@

application.run(
port=my_host_port,
threaded=True,

# 如果配置文件中开启了多进程, 那么就关掉多线程, 否则默认启用多线程
threaded="processes" not in built_in_server_extra_params,

# 如果你想直接用本程序给外网访问, 请在 config.py 末尾加两行配置
# !!警告!! 无论如何都不要修改 config_default.py, 否则程序将无法通过 git pull 来升级
Expand All @@ -35,4 +38,6 @@
debug=built_in_server_debug, # 默认是开启debug模式的
# 默认只允许本机访问, 如果你希望让外网访问, 请根据上面的注释修改配置文件
host=built_in_server_host,

**built_in_server_extra_params # extra params
)

0 comments on commit 45bbabe

Please sign in to comment.