-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
67 lines (56 loc) · 1.84 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
56
57
58
59
60
61
62
63
64
65
66
67
import pkg_resources
from fastapi import FastAPI
from fastapi.openapi.utils import get_openapi
from starlette.responses import RedirectResponse, JSONResponse
from routers import (
auth, video, photo, user,
album, story, insights
)
app = FastAPI()
app.include_router(auth.router)
# app.include_router(media.router)
# app.include_router(video.router)
app.include_router(photo.router)
app.include_router(user.router)
# app.include_router(igtv.router)
# app.include_router(clip.router)
# app.include_router(album.router)
app.include_router(story.router)
app.include_router(insights.router)
@app.get("/", tags=["system"], summary="Redirect to /docs")
async def root():
"""Redirect to / this default after load page.
"""
return RedirectResponse(url="/docs")
@app.get("/version", tags=["system"], summary="Get dependency versions")
async def version():
"""Get dependency versions
"""
versions = {}
for name in ('instagrapi', ):
item = pkg_resources.require(name)
if item:
versions[name] = item[0].version
return versions
@app.exception_handler(Exception)
async def handle_exception(request, exc: Exception):
return JSONResponse({
"detail": str(exc),
"exception type": str(type(exc).__name__)
}, status_code=500)
def custom_openapi():
if app.openapi_schema:
return app.openapi_schema
# for route in app.routes:
# body_field = getattr(route, 'body_field', None)
# if body_field:
# body_field.type_.__name__ = 'name'
openapi_schema = get_openapi(
title="KOP-API-INSTAGRAM-v1.0.0",
version="1.0.0",
description="API RESTful - PT. krisanthium offset printing. developer by @EDP Team",
routes=app.routes,
)
app.openapi_schema = openapi_schema
return app.openapi_schema
app.openapi = custom_openapi