INNER CODE UNIT · Python
create_app
416rehman/DeepZero · src/deepzero/api/server.py:25
def create_app(work_dir: Path):
try:
from starlette.applications import Starlette
from starlette.responses import JSONResponse
from starlette.routing import Route
except ImportError as exc:
raise ImportError("starlette required for serve mode: pip install deepzero[serve]") from exc
from deepzero.engine.state import StateStore
store = StateStore(work_dir)
async def _run_sync(fn, *args):
# run synchronous file I/O in a thread to avoid blocking the event loop
loop = asyncio.get_running_loop()
return await loop.run_in_executor(None, partial(fn, *args))
async def health(request: Request) -> JSONResponseType: