-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
47 lines (33 loc) · 1.02 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright SquirrelNetwork
from dotenv import load_dotenv
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from config import Config, Session
from core.api import auth, blacklist, group, statistics, test, tools, users
from core.database import init_db
# load .env file
load_dotenv()
# Config
conf = Session.config = Config()
# Fastapi instance
app = FastAPI(title="Nebula API", docs_url="/", version="4.0.0")
# CORS
app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
# Start db
init_db(app)
# API EndPoint
app.include_router(auth.auth)
app.include_router(blacklist.api_blacklist, prefix="/v2")
app.include_router(group.api_group, prefix="/v2")
app.include_router(statistics.api_statistics, prefix="/v2")
app.include_router(test.api_test, prefix="/v2")
app.include_router(tools.api_bot_service, prefix="/v2")
app.include_router(users.api_users, prefix="/v2")