Starting server and forwarding it to onion works
This commit is contained in:
20
dragonion_server/modules/server/server.py
Normal file
20
dragonion_server/modules/server/server.py
Normal file
@@ -0,0 +1,20 @@
|
||||
from fastapi import FastAPI
|
||||
import uvicorn
|
||||
from dragonion_server.utils.onion import get_available_port
|
||||
from .integration import integrate_onion
|
||||
from .routes import router
|
||||
|
||||
|
||||
def get_app(port: int, name: str) -> FastAPI:
|
||||
onion = integrate_onion(port, name)
|
||||
return FastAPI(
|
||||
title=f'dragonion-server: {name}',
|
||||
description=f'Secure dragonion chat endpoint server - service {name}',
|
||||
on_shutdown=[onion.cleanup]
|
||||
)
|
||||
|
||||
|
||||
def run(name: str, port: int = get_available_port()):
|
||||
app = get_app(port, name)
|
||||
app.include_router(router)
|
||||
uvicorn.run(app, host='0.0.0.0', port=port)
|
||||
Reference in New Issue
Block a user