code: def _start_server(
      serve_dir: str,
      host: str = "localhost",
      port: int = -1,
      path: str = "/",
      log_file: str = "",
      root_path: str = "",
  ) -> None:
      if port == -1:
          port = find_free_network_port()
      fastapi_service = FastAPI()
  
      fastapi_service.add_middleware(
          CORSMiddleware,
          allow_origins=["*"],
          allow_credentials=True,
          allow_methods=["*"],
          allow_headers=["*"],
      )
      # trailing / is required for urljoin to properly join the path. In case of
      # multiple trailing /, urljoin removes them
      fastapi_service.get(
          urljoin(f"{path}/", "healthz"), status_code=200
      )(_healthz)
      fastapi_service.mount(
          urljoin(path, root_path),
          StaticFiles(directory=serve_dir, html=True),
          name="static",
      )
  
      log_config = (
          _get_log_config(log_file)
          if log_file
          else uvicorn.config.LOGGING_CONFIG
      )
  
      uvicorn.run(
          app=fastapi_service,
          host=host,
          port=port,
          log_config=log_config,
          root_path=root_path,
      )
  
file_path: pytorch-lightning/src/lightning/app/frontend/web.py
imports: import multiprocessing
  from argparse import ArgumentParser
  from typing import Optional
  from urllib.parse import urljoin
  import uvicorn
  from fastapi import FastAPI
  from fastapi.middleware.cors import CORSMiddleware
  from starlette.staticfiles import StaticFiles
  from lightning.app.frontend.frontend import Frontend
  from lightning.app.utilities.log import get_logfile
  from lightning.app.utilities.network import find_free_network_port
label_desc: Use image node_id 2 for calling a global function with example usage: _start_server(serve_dir, host, port, path, log_file, root_path) without return types