You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
888 B
36 lines
888 B
from __future__ import annotations |
|
|
|
from pathlib import Path |
|
|
|
import uvicorn |
|
|
|
from app.main import CONF_PATH |
|
from app.security import ensure_tls_certificate |
|
|
|
|
|
def main() -> None: |
|
import json |
|
|
|
with CONF_PATH.open("r", encoding="utf-8") as conf_file: |
|
conf = json.load(conf_file) |
|
|
|
server_conf = conf.get("server", {}) |
|
host = server_conf.get("host", "0.0.0.0") |
|
port = int(server_conf.get("port", 8443)) |
|
|
|
cert_path = (Path(__file__).resolve().parent / server_conf.get("tls_cert", "certs/cert.pem")).resolve() |
|
key_path = (Path(__file__).resolve().parent / server_conf.get("tls_key", "certs/key.pem")).resolve() |
|
|
|
ensure_tls_certificate(cert_path, key_path) |
|
|
|
uvicorn.run( |
|
"app.main:app", |
|
host=host, |
|
port=port, |
|
ssl_certfile=str(cert_path), |
|
ssl_keyfile=str(key_path), |
|
) |
|
|
|
|
|
if __name__ == "__main__": |
|
main()
|
|
|