Start the API server using uvicorn. Parameters: host (str): The host for the server. port (int): The port for the server.
(host: str = "0.0.0.0", port: int = 8000)
| 173 | |
| 174 | |
| 175 | def start_api_server(host: str = "0.0.0.0", port: int = 8000): |
| 176 | """ |
| 177 | Start the API server using uvicorn. |
| 178 | Parameters: |
| 179 | host (str): The host for the server. |
| 180 | port (int): The port for the server. |
| 181 | """ |
| 182 | try: |
| 183 | logger.info("Starting server at %s:%s", host, port) |
| 184 | |
| 185 | uvicorn.run(app, host=host, port=port) |
| 186 | except Exception as e: |
| 187 | logger.exception(f"Failed to start server: {e}") |
| 188 | # Here you could add any cleanup code or error recovery code. |
| 189 | raise e |
| 190 | |
| 191 | |
| 192 | if __name__ == "__main__": |