MCPcopy Create free account
hub / github.com/reactive-python/reactpy / _setup_common_routes

Function _setup_common_routes

src/py/reactpy/reactpy/backend/flask.py:152–177  ·  view source on GitHub ↗
(
    api_blueprint: Blueprint,
    spa_blueprint: Blueprint,
    options: Options,
)

Source from the content-addressed store, hash-verified

150
151
152def _setup_common_routes(
153 api_blueprint: Blueprint,
154 spa_blueprint: Blueprint,
155 options: Options,
156) -> None:
157 cors_options = options.cors
158 if cors_options: # nocov
159 cors_params = cors_options if isinstance(cors_options, dict) else {}
160 CORS(api_blueprint, **cors_params)
161
162 @api_blueprint.route(f"/{ASSETS_PATH.name}/<path:path>")
163 def send_assets_dir(path: str = "") -> Any:
164 return send_file(safe_client_build_dir_path(f"assets/{path}"))
165
166 @api_blueprint.route(f"/{MODULES_PATH.name}/<path:path>")
167 def send_modules_dir(path: str = "") -> Any:
168 return send_file(safe_web_modules_dir_path(path), mimetype="text/javascript")
169
170 index_html = read_client_index_html(options)
171
172 if options.serve_index_route:
173
174 @spa_blueprint.route("/")
175 @spa_blueprint.route("/<path:_>")
176 def send_client_dir(_: str = "") -> Any:
177 return index_html
178
179
180def _setup_single_view_dispatcher_route(

Callers 1

configureFunction · 0.70

Calls 1

read_client_index_htmlFunction · 0.90

Tested by

no test coverage detected