Add support for running the server with SSL (#994)

This commit is contained in:
Radoslav Gerganov 2023-12-12 03:47:11 +02:00 committed by GitHub
parent ef22e478db
commit 8e44a32075
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 1 deletions

View file

@ -96,5 +96,6 @@ if __name__ == "__main__":
app = create_app(settings=settings) app = create_app(settings=settings)
uvicorn.run( uvicorn.run(
app, host=os.getenv("HOST", settings.host), port=int(os.getenv("PORT", settings.port)) app, host=os.getenv("HOST", settings.host), port=int(os.getenv("PORT", settings.port)),
ssl_keyfile=settings.ssl_keyfile, ssl_certfile=settings.ssl_certfile
) )

View file

@ -150,6 +150,13 @@ class Settings(BaseSettings):
# Server Params # Server Params
host: str = Field(default="localhost", description="Listen address") host: str = Field(default="localhost", description="Listen address")
port: int = Field(default=8000, description="Listen port") port: int = Field(default=8000, description="Listen port")
# SSL Params
ssl_keyfile: Optional[str] = Field(
default=None, description="SSL key file for HTTPS"
)
ssl_certfile: Optional[str] = Field(
default=None, description="SSL certificate file for HTTPS"
)
interrupt_requests: bool = Field( interrupt_requests: bool = Field(
default=True, default=True,
description="Whether to interrupt requests when a new request is received.", description="Whether to interrupt requests when a new request is received.",