forked from erev0s/VAmPI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.py
27 lines (22 loc) · 920 Bytes
/
config.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
import os
import connexion
from flask import jsonify
from flask_sqlalchemy import SQLAlchemy
from connexion.exceptions import ProblemException
vuln_app = connexion.App(__name__, specification_dir='./openapi_specs')
SQLALCHEMY_DATABASE_URI = 'sqlite:///' + os.path.join(vuln_app.app.root_path, 'database/database.db')
vuln_app.app.config['SQLALCHEMY_DATABASE_URI'] = SQLALCHEMY_DATABASE_URI
vuln_app.app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
vuln_app.app.config['SECRET_KEY'] = 'random'
# start the db
db = SQLAlchemy(vuln_app.app)
def custom_problem_handler(error):
# Custom error handler for clarity in structure
response = jsonify({
"status": "fail",
"message": getattr(error, "detail", "An error occurred"),
})
response.status_code = error.status
return response
vuln_app.add_error_handler(ProblemException, custom_problem_handler)
vuln_app.add_api('openapi3.yml')