MCPcopy Index your code
hub / github.com/reactive-python/reactpy / run

Function run

src/py/reactpy/reactpy/backend/utils.py:26–48  ·  view source on GitHub ↗

Run a component with a development server

(
    component: RootComponentConstructor,
    host: str = "127.0.0.1",
    port: int | None = None,
    implementation: BackendType[Any] | None = None,
)

Source from the content-addressed store, hash-verified

24
25
26def run(
27 component: RootComponentConstructor,
28 host: str = "127.0.0.1",
29 port: int | None = None,
30 implementation: BackendType[Any] | None = None,
31) -> None:
32 """Run a component with a development server"""
33 logger.warning(_DEVELOPMENT_RUN_FUNC_WARNING)
34
35 implementation = implementation or import_module("reactpy.backend.default")
36 app = implementation.create_development_app()
37 implementation.configure(app, component)
38 port = port or find_available_port(host)
39 app_cls = type(app)
40
41 logger.info(
42 "ReactPy is running with '%s.%s' at http://%s:%s",
43 app_cls.__module__,
44 app_cls.__name__,
45 host,
46 port,
47 )
48 asyncio.run(implementation.serve_development_app(app, host, port))
49
50
51def find_available_port(host: str, port_min: int = 8000, port_max: int = 9000) -> int:

Callers 15

main.pyFile · 0.90
main.pyFile · 0.90
wrap_in_div.pyFile · 0.90
todo_list.pyFile · 0.90
simple_photo.pyFile · 0.90
nested_photos.pyFile · 0.90

Calls 5

find_available_portFunction · 0.85
configureMethod · 0.80
serve_development_appMethod · 0.80
runMethod · 0.45

Tested by

no test coverage detected