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

Function start_server

pywebio/platform/fastapi.py:148–187  ·  view source on GitHub ↗

Start a FastAPI/Starlette server using uvicorn to provide the PyWebIO application as a web service. :param bool debug: Boolean indicating if debug tracebacks should be returned on errors. :param uvicorn_settings: Additional keyword arguments passed to ``uvicorn.run()``. For details,

(applications, port=0, host='', cdn=True, reconnect_timeout=0,
                 static_dir=None, remote_access=False, debug=False,
                 allowed_origins=None, check_origin=None,
                 auto_open_webbrowser=False,
                 max_payload_size='200M',
                 **uvicorn_settings)

Source from the content-addressed store, hash-verified

146
147
148def start_server(applications, port=0, host='', cdn=True, reconnect_timeout=0,
149 static_dir=None, remote_access=False, debug=False,
150 allowed_origins=None, check_origin=None,
151 auto_open_webbrowser=False,
152 max_payload_size='200M',
153 **uvicorn_settings):
154 """Start a FastAPI/Starlette server using uvicorn to provide the PyWebIO application as a web service.
155
156 :param bool debug: Boolean indicating if debug tracebacks should be returned on errors.
157 :param uvicorn_settings: Additional keyword arguments passed to ``uvicorn.run()``.
158 For details, please refer: https://www.uvicorn.org/settings/
159
160 The rest arguments of ``start_server()`` have the same meaning as for :func:`pywebio.platform.tornado.start_server`
161
162 .. versionadded:: 1.3
163 """
164
165 app = asgi_app(applications, cdn=cdn, reconnect_timeout=reconnect_timeout,
166 static_dir=static_dir, debug=debug,
167 allowed_origins=allowed_origins, check_origin=check_origin)
168
169 if auto_open_webbrowser:
170 asyncio.get_event_loop().create_task(open_webbrowser_on_server_started('127.0.0.1', port))
171
172 if not host:
173 host = '0.0.0.0'
174
175 if port == 0:
176 port = get_free_port()
177
178 print_listen_address(host, port)
179
180 if remote_access:
181 start_remote_access_service(local_port=port)
182
183 page.MAX_PAYLOAD_SIZE = max_payload_size = parse_file_size(max_payload_size)
184 uvicorn_settings = uvicorn_settings or {}
185 uvicorn_settings.setdefault('ws_max_size', max_payload_size)
186
187 uvicorn.run(app, host=host, port=port, **uvicorn_settings)
188
189
190def asgi_app(applications, cdn=True, reconnect_timeout=0, static_dir=None, debug=False, allowed_origins=None,

Callers 1

start_test_serverFunction · 0.90

Calls 7

asgi_appFunction · 0.85
get_free_portFunction · 0.85
print_listen_addressFunction · 0.85
parse_file_sizeFunction · 0.85
runMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…