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

Function start_server

pywebio/platform/flask.py:134–181  ·  view source on GitHub ↗

Start a Flask server to provide the PyWebIO application as a web service. :param int session_expire_seconds: Session expiration time, in seconds(default 600s). If no client message is received within ``session_expire_seconds``, the session will be considered expired. :param int sessi

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

Source from the content-addressed store, hash-verified

132
133
134def start_server(applications, port=8080, host='', cdn=True,
135 static_dir=None, remote_access=False,
136 allowed_origins=None, check_origin=None,
137 session_expire_seconds=None,
138 session_cleanup_interval=None,
139 debug=False,
140 max_payload_size='200M',
141 **flask_options):
142 """Start a Flask server to provide the PyWebIO application as a web service.
143
144 :param int session_expire_seconds: Session expiration time, in seconds(default 600s).
145 If no client message is received within ``session_expire_seconds``, the session will be considered expired.
146 :param int session_cleanup_interval: Session cleanup interval, in seconds(default 300s).
147 The server will periodically clean up expired sessions and release the resources occupied by the sessions.
148 :param bool debug: Flask debug mode.
149 If enabled, the server will automatically reload for code changes.
150 :param int/str max_payload_size: Max size of a request body which Flask can accept.
151 :param flask_options: Additional keyword arguments passed to the ``flask.Flask.run``.
152 For details, please refer: https://flask.palletsprojects.com/en/1.1.x/api/#flask.Flask.run
153
154 The arguments of ``start_server()`` have the same meaning as for :func:`pywebio.platform.tornado.start_server`
155 """
156 if not host:
157 host = '0.0.0.0'
158
159 if port == 0:
160 port = get_free_port()
161
162 app = wsgi_app(applications, cdn=cdn, static_dir=static_dir, allowed_origins=allowed_origins,
163 check_origin=check_origin, session_expire_seconds=session_expire_seconds,
164 session_cleanup_interval=session_cleanup_interval, max_payload_size=max_payload_size)
165
166 print_listen_address(host, port)
167
168 debug = Session.debug = os.environ.get('PYWEBIO_DEBUG', debug)
169 if not debug:
170 logging.getLogger('werkzeug').setLevel(logging.WARNING)
171
172 running_from_reloader = werkzeug.serving.is_running_from_reloader()
173 if remote_access and not running_from_reloader:
174 start_remote_access_service(local_port=port)
175
176 has_coro_target = any(iscoroutinefunction(target) or isgeneratorfunction(target) for
177 target in make_applications(applications).values())
178 if has_coro_target and not running_from_reloader:
179 threading.Thread(target=run_event_loop, daemon=True).start()
180
181 app.run(host=host, port=port, debug=debug, threaded=True, use_evalex=False, **flask_options)

Callers 15

start_test_serverFunction · 0.90
start_test_serverFunction · 0.90
start_test_serverFunction · 0.90
start_test_serverFunction · 0.90
start_test_serverFunction · 0.90
start_test_serverFunction · 0.90
start_test_serverFunction · 0.90
chatgpt.pyFile · 0.90
bmi.pyFile · 0.90
input_usage.pyFile · 0.90
wordle.pyFile · 0.90
theme.pyFile · 0.90

Calls 9

get_free_portFunction · 0.85
print_listen_addressFunction · 0.85
iscoroutinefunctionFunction · 0.85
isgeneratorfunctionFunction · 0.85
make_applicationsFunction · 0.85
wsgi_appFunction · 0.70
getMethod · 0.45
runMethod · 0.45

Tested by 1

start_test_serverFunction · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…