MCPcopy Index your code
hub / github.com/pywebio/PyWebIO / start_server

Function start_server

pywebio/platform/tornado_http.py:111–164  ·  view source on GitHub ↗

Start a Tornado server to provide the PyWebIO application as a web service. The Tornado server communicates with the browser by HTTP protocol. :param int session_expire_seconds: Session expiration time, in seconds(default 60s). If no client message is received within ``session_expir

(applications, port=8080, host='',
                 debug=False, cdn=True, static_dir=None,
                 allowed_origins=None, check_origin=None,
                 auto_open_webbrowser=False,
                 session_expire_seconds=None,
                 session_cleanup_interval=None,
                 max_payload_size='200M',
                 **tornado_app_settings)

Source from the content-addressed store, hash-verified

109
110
111def start_server(applications, port=8080, host='',
112 debug=False, cdn=True, static_dir=None,
113 allowed_origins=None, check_origin=None,
114 auto_open_webbrowser=False,
115 session_expire_seconds=None,
116 session_cleanup_interval=None,
117 max_payload_size='200M',
118 **tornado_app_settings):
119 """Start a Tornado server to provide the PyWebIO application as a web service.
120
121 The Tornado server communicates with the browser by HTTP protocol.
122
123 :param int session_expire_seconds: Session expiration time, in seconds(default 60s).
124 If no client message is received within ``session_expire_seconds``, the session will be considered expired.
125 :param int session_cleanup_interval: Session cleanup interval, in seconds(default 120s).
126 The server will periodically clean up expired sessions and release the resources occupied by the sessions.
127 :param int/str max_payload_size: Max size of a request body which Tornado can accept.
128
129 The rest arguments of ``start_server()`` have the same meaning as for :func:`pywebio.platform.tornado.start_server`
130
131 .. versionadded:: 1.2
132 """
133
134 if not host:
135 host = '0.0.0.0'
136
137 cdn = cdn_validation(cdn, 'warn')
138
139 set_ioloop(tornado.ioloop.IOLoop.current()) # to enable bokeh app
140
141 cdn = cdn_validation(cdn, 'warn') # if CDN is not available, warn user and disable CDN
142
143 page.MAX_PAYLOAD_SIZE = max_payload_size = parse_file_size(max_payload_size)
144
145 debug = Session.debug = os.environ.get('PYWEBIO_DEBUG', debug)
146
147 tornado_app_settings.setdefault('websocket_max_message_size', max_payload_size)
148 tornado_app_settings['websocket_max_message_size'] = parse_file_size(
149 tornado_app_settings['websocket_max_message_size'])
150 tornado_app_settings['debug'] = debug
151
152 handler = webio_handler(applications, cdn,
153 session_expire_seconds=session_expire_seconds,
154 session_cleanup_interval=session_cleanup_interval,
155 allowed_origins=allowed_origins, check_origin=check_origin)
156
157 _, port = _setup_server(webio_handler=handler, port=port, host=host, static_dir=static_dir,
158 max_buffer_size=parse_file_size(max_payload_size), **tornado_app_settings)
159
160 print_listen_address(host, port)
161 if auto_open_webbrowser:
162 tornado.ioloop.IOLoop.current().spawn_callback(open_webbrowser_on_server_started, host or '127.0.0.1', port)
163
164 tornado.ioloop.IOLoop.current().start()

Callers 1

start_test_serverFunction · 0.90

Calls 7

cdn_validationFunction · 0.85
set_ioloopFunction · 0.85
parse_file_sizeFunction · 0.85
_setup_serverFunction · 0.85
print_listen_addressFunction · 0.85
webio_handlerFunction · 0.70
getMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…