Init webpanel
This commit is contained in:
43
core/scripts/webpanel/app.py
Normal file
43
core/scripts/webpanel/app.py
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
import sys
|
||||||
|
from fastapi import FastAPI
|
||||||
|
from fastapi.templating import Jinja2Templates
|
||||||
|
from fastapi import Request
|
||||||
|
from starlette.middleware.sessions import SessionMiddleware
|
||||||
|
from starlette.staticfiles import StaticFiles
|
||||||
|
|
||||||
|
import routers
|
||||||
|
|
||||||
|
# Append directory of cli.py to be able to import it
|
||||||
|
HYSTERIA_CORE_DIR = '/etc/hysteria/core/'
|
||||||
|
sys.path.append(HYSTERIA_CORE_DIR)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
app = FastAPI()
|
||||||
|
|
||||||
|
app.mount('/assets', StaticFiles(directory='asset'), name='assets')
|
||||||
|
app.add_middleware(SessionMiddleware, secret_key='your-secret-key')
|
||||||
|
|
||||||
|
|
||||||
|
templates = Jinja2Templates(directory='templates')
|
||||||
|
|
||||||
|
app.include_router(router=routers.user.router,prefix='/user')
|
||||||
|
app.include_router(router=routers.hysteria.router,prefix='/settings/hysteria')
|
||||||
|
app.include_router(router=routers.warp.router,prefix='/settings/warp')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@app.get('/')
|
||||||
|
async def index(request: Request):
|
||||||
|
return templates.TemplateResponse('index.html', {'request': request})
|
||||||
|
return templates.TemplateResponse('index.html', {'request': request})
|
||||||
|
|
||||||
|
@app.get('/home')
|
||||||
|
async def home(request: Request):
|
||||||
|
return await index(request)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
import uvicorn
|
||||||
|
uvicorn.run(app, host='127.0.0.1', port=8080)
|
||||||
16
core/scripts/webpanel/requirements.txt
Normal file
16
core/scripts/webpanel/requirements.txt
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
annotated-types==0.7.0
|
||||||
|
anyio==4.8.0
|
||||||
|
click==8.1.8
|
||||||
|
fastapi==0.115.6
|
||||||
|
h11==0.14.0
|
||||||
|
idna==3.10
|
||||||
|
itsdangerous==2.2.0
|
||||||
|
Jinja2==3.1.5
|
||||||
|
MarkupSafe==3.0.2
|
||||||
|
pydantic==2.10.5
|
||||||
|
pydantic_core==2.27.2
|
||||||
|
python-multipart==0.0.20
|
||||||
|
sniffio==1.3.1
|
||||||
|
starlette==0.41.3
|
||||||
|
typing_extensions==4.12.2
|
||||||
|
uvicorn==0.34.0
|
||||||
Reference in New Issue
Block a user