Skip to content

Commit

Permalink
Refactor(home-endpoints)!: refactor home endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
erfjab committed Aug 18, 2024
1 parent 6918f7f commit 36532a9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 17 deletions.
14 changes: 8 additions & 6 deletions app/__init__.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
import logging

from apscheduler.schedulers.background import BackgroundScheduler
from fastapi import FastAPI, Request, status
from fastapi.encoders import jsonable_encoder
from fastapi.exceptions import RequestValidationError
from fastapi.middleware.cors import CORSMiddleware
from fastapi.responses import JSONResponse
from fastapi.responses import JSONResponse, HTMLResponse
from fastapi.routing import APIRoute
from fastapi_responses import custom_openapi

from config import DOCS, XRAY_SUBSCRIPTION_PATH
from config import DOCS, XRAY_SUBSCRIPTION_PATH, HOME_PAGE_TEMPLATE
from app import dashboard, telegram, routers, jobs # noqa
from app.routers import api_router
from app.templates import render_template

__version__ = "0.6.0"


app = FastAPI(
title="MarzbanAPI",
description="Unified GUI Censorship Resistant Solution Powered by Xray",
Expand Down Expand Up @@ -43,10 +42,8 @@ def use_route_names_as_operation_ids(app: FastAPI) -> None:
if isinstance(route, APIRoute):
route.operation_id = route.name


use_route_names_as_operation_ids(app)


@app.on_event("startup")
def on_startup():
paths = [f"{r.path}/" for r in app.routes]
Expand All @@ -70,3 +67,8 @@ def validation_exception_handler(request: Request, exc: RequestValidationError):
status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,
content=jsonable_encoder({"detail": details}),
)


@app.get("/", response_class=HTMLResponse)
def base():
return render_template(HOME_PAGE_TEMPLATE)
11 changes: 0 additions & 11 deletions app/routers/home.py

This file was deleted.

0 comments on commit 36532a9

Please sign in to comment.