-
Notifications
You must be signed in to change notification settings - Fork 0
/
swaggerConfig.py
90 lines (72 loc) · 2.52 KB
/
swaggerConfig.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
from flask import Flask, g, request
from flask_restx import Api
import time, datetime, os, json, decimal
# from flask_jwt_extended import get_jwt_identity
import threading
# siteroot = os.path.realpath(os.path.dirname(__file__) + "/service/auth/")
# json_url = os.path.join(siteroot, "OAuth.json")
# OAuthJson = json.loads(open(json_url).read())
app = Flask(__name__)
# app.config["JWT_SECRET_KEY"] = "P+APugQ}&?cwwPXA]u+cEcfVnp8i]&"
# app.config["JWT_ACCESS_TOKEN_EXPIRES"] = False
# jwt = JWTManager(app)
# @app.before_request
# def before_request():
# g.start_time = time.time()
# g.response = {}
# def myconverter(o):
# if isinstance(o, datetime.datetime) or isinstance(o, datetime.date):
# return o.__str__()
# elif isinstance(o, decimal.Decimal):
# return float(o)
# @app.after_request
# def after_request(res):
# body = (
# (request.json if request.json is not None else dict(request.form))
# if request.method != "GET"
# else None
# )
# userid = None
# try:
# userid = get_jwt_identity()
# except Exception as e:
# pass
# newObject = [
# {
# "userid": userid,
# "path": request.path,
# "method": request.method,
# "browser": request.user_agent.browser,
# "browser_version": request.user_agent.version,
# "os": request.user_agent.platform,
# "ip_address": request.remote_addr,
# "params": dict(request.args),
# "body": body,
# "status": (g.response).get("status"),
# "duration": int((time.time() - g.start_time) * 1000),
# }
# ]
# threading.Thread(target=ServerLog, args=(newObject), daemon=True).start()
# try:
# if (res.get_data()).decode("utf-8") == "null\n":
# res.set_data(json.dumps(g.response, default=myconverter))
# return res
# except Exception as e:
# return res
# def ServerLog(logObject):
# StoreLog().log(logObject)
# app.config.SWAGGER_UI_OAUTH_CLIENT_ID = OAuthJson["google"]["clientId"]
# app.config.SWAGGER_UI_OAUTH_CLIENT_SECRET = OAuthJson["google"]["clientSecret"]
# app.config.SWAGGER_UI_OAUTH_REALM = "-"
# app.config.SWAGGER_UI_OAUTH_APP_NAME = "IndiaConnects"
# authorizations = {
# "api_key": {"type": "apiKey", "in": "header", "name": "AUTHORIZATION"}
# }
api = Api(
app,
version="1.0",
title="GMusic",
description="API DOCUMENTATION",
# security=["api_key"],
# authorizations=authorizations,
)