-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
39 lines (32 loc) · 1016 Bytes
/
app.py
File metadata and controls
39 lines (32 loc) · 1016 Bytes
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
from flask import Flask, jsonify
from flask_restful import Api
from flask_jwt_extended import JWTManager
from flask_mysqldb import MySQL
from config import Config
from user_routes import user_blueprint
from book_routes import book_blueprint
from flask_swagger_ui import get_swaggerui_blueprint
import json
app = Flask(__name__)
app.config.from_object(Config)
mysql = MySQL(app)
jwt = JWTManager(app)
app.register_blueprint(user_blueprint, url_prefix='/api')
app.register_blueprint(book_blueprint, url_prefix='/api')
# Configure Swagger UI
SWAGGER_URL = '/swagger'
API_URL = 'http://127.0.0.1:3000/swagger.json'
swaggerui_blueprint = get_swaggerui_blueprint(
SWAGGER_URL,
API_URL,
config={
'app_name': "Book Store API"
}
)
app.register_blueprint(swaggerui_blueprint, url_prefix=SWAGGER_URL)
@app.route('/swagger.json')
def swagger():
with open('swagger.json', 'r') as f:
return jsonify(json.load(f))
if __name__ == "__main__":
app.run(host="localhost", port=int("3000"))