Run the backend. Args: host: The app host port: The app port loglevel: The log level. frontend_present: Whether the frontend is present.
(
host: str,
port: int,
loglevel: constants.LogLevel = constants.LogLevel.ERROR,
frontend_present: bool = False,
)
| 447 | |
| 448 | |
| 449 | def run_backend( |
| 450 | host: str, |
| 451 | port: int, |
| 452 | loglevel: constants.LogLevel = constants.LogLevel.ERROR, |
| 453 | frontend_present: bool = False, |
| 454 | ): |
| 455 | """Run the backend. |
| 456 | |
| 457 | Args: |
| 458 | host: The app host |
| 459 | port: The app port |
| 460 | loglevel: The log level. |
| 461 | frontend_present: Whether the frontend is present. |
| 462 | """ |
| 463 | web_dir = get_web_dir() |
| 464 | # Create a .nocompile file to skip compile for backend. |
| 465 | if web_dir.exists(): |
| 466 | (web_dir / constants.NOCOMPILE_FILE).touch() |
| 467 | |
| 468 | if not frontend_present: |
| 469 | notify_backend(host) |
| 470 | |
| 471 | # Run the backend in development mode. |
| 472 | if should_use_granian(): |
| 473 | # We import reflex app because this lets granian cache the module |
| 474 | import reflex.app # noqa: F401 |
| 475 | |
| 476 | run_granian_backend(host, port, loglevel) |
| 477 | else: |
| 478 | run_uvicorn_backend(host, port, loglevel) |
| 479 | |
| 480 | |
| 481 | def _has_child_file(directory: Path, file_name: str) -> bool: |
nothing calls this directly
no test coverage detected