Refactoring, added docstrings

This commit is contained in:
BarsTiger
2023-07-16 00:07:35 +03:00
parent e9477dfde7
commit 1662127c85
11 changed files with 135 additions and 64 deletions

View File

@@ -6,6 +6,12 @@ from .routes import router
def get_app(port: int, name: str) -> FastAPI:
"""
Creates FastAPI object and runs integrate_onion
:param port: Must be same with port on which uvicorn is running
:param name: Name of service
:return: FastAPI object with onion.cleanup function on shutdown
"""
onion = integrate_onion(port, name)
return FastAPI(
title=f'dragonion-server: {name}',
@@ -15,6 +21,12 @@ def get_app(port: int, name: str) -> FastAPI:
def run(name: str, port: int | None = get_available_port()):
"""
Runs service with specified name and starts onion
:param name: Name of service
:param port: Port where to start service, if not specified - gets random available
:return:
"""
if port is None:
port = get_available_port()
app = get_app(port, name)