This repository has been archived by the owner on Apr 15, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
55 lines (45 loc) · 1.94 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
48
49
50
51
52
53
54
55
from fastapi import FastAPI
from starlette.responses import RedirectResponse
from fastapi.openapi.docs import get_redoc_html
from fastapi import Depends
from fastapi.security.api_key import APIKey
from routers import guild_info, auto_threads, economy, private_voice_channels, sticky_messages, support, giveaway, suggestions, nickname, reaction_roles, autopublish, levels, notifications, applications, reminders, user_statistics
import uvicorn, constants, utils
app = FastAPI(openapi_url=None, title="Nom Industries API")
app.include_router(guild_info.guild_main_router)
app.include_router(guild_info.guild_mod_router)
app.include_router(guild_info.guild_logging_config_router)
app.include_router(guild_info.guild_stats_router)
app.include_router(auto_threads.router)
app.include_router(economy.router)
app.include_router(private_voice_channels.router)
app.include_router(sticky_messages.router)
app.include_router(support.router)
app.include_router(giveaway.router)
app.include_router(suggestions.router)
app.include_router(nickname.router)
app.include_router(reaction_roles.router)
app.include_router(autopublish.router)
app.include_router(levels.router)
app.include_router(notifications.router)
app.include_router(applications.router)
app.include_router(reminders.router)
app.include_router(user_statistics.router)
@app.get("/", include_in_schema=False)
def home():
return "nom!"
@app.get("/json")
def json_api(api_key: str = None):
if api_key != constants.DB_API_KEY:
return RedirectResponse(url="https://www.youtube.com/watch?v=dQw4w9WgXcQ")
openapi = app.openapi()
openapi["paths"].pop("/json")
openapi["paths"].pop("/docs")
openapi["paths"].pop("/redoc")
return openapi
@app.get("/docs")
@app.get("/redoc")
def funny(api_key: APIKey = Depends(utils.validate_api_key)):
return get_redoc_html(title="Big Bot", openapi_url="/json?api_key={API_KEY}")
if __name__ == '__main__':
uvicorn.run(app, host="0.0.0.0", port=8000)