-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
47 lines (35 loc) · 1.09 KB
/
app.py
File metadata and controls
47 lines (35 loc) · 1.09 KB
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
import os, sys
from flask import Flask
import pathlib
from flask_restx import Api, Resource, fields
# from werkzeug.middleware.proxy_fix import ProxyFix
# import coloredlogs, logging as log
# coloredlogs.install()
from main.apis.user import api as User
from main.apis.template import api as Template
from main.apis.auth import api as Auth
from main import create_app
# from flask_pymongo import PyMongo
# Init app
app = Flask(__name__)
authorizations = {"token": {"type": "apiKey", "in": "header", "name": "Authorization"}}
config_name = os.getenv("FLASK_CONFIG")
app = create_app(config_name)
VERSION = "v1"
api = Api(
app,
authorizations=authorizations,
version="1.0",
title="API docs",
description="A simple REST API with JWT authentication.",
doc="/docs",
)
app.config["jwt"]._set_error_handler_callbacks(api)
app.config["ROOT_DIR"] = pathlib.Path(__file__).parent.absolute()
# Endpoints
api.add_namespace(Auth, path=f"/{VERSION}")
api.add_namespace(User, path=f"/{VERSION}")
api.add_namespace(Template, path=f"/{VERSION}")
# Run Server
if __name__ == "__main__":
app.run()