-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
51 lines (37 loc) · 1.36 KB
/
app.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
from flask_restful import Api
from db import db
from flask import Flask
from resources.evaluation import Evaluate, EvaluateList
from resources.datasets import DatasetResource, DatasetList
from resources.mlmodels import MLModelResource, ModelList
from flask_swagger_ui import get_swaggerui_blueprint
import logging
#logging config
logging.basicConfig(filename='record.log', level=logging.DEBUG, format=f'%(asctime)s %(levelname)s %(name)s %(threadName)s : %(message)s')
app=Flask(__name__)
### swagger specific ###
SWAGGER_URL = '/swagger'
API_URL = '/static/swagger.json'
SWAGGERUI_BLUEPRINT = get_swaggerui_blueprint(
SWAGGER_URL,
API_URL,
config={
'app_name': "Model Evaluation"
}
)
app.register_blueprint(SWAGGERUI_BLUEPRINT, url_prefix=SWAGGER_URL)
### end swagger specific ###
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///data.db'
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
app.secret_key = '#521637819082308ryfbbjdwd89'
api = Api(app)
@app.before_first_request
def create_tables():
db.create_all()
api.add_resource(Evaluate,"/modelEvaluations/<int:eval_id>")
api.add_resource(EvaluateList,"/modelEvaluations")
api.add_resource(DatasetResource,"/datasets/<int:dataset_id>")
api.add_resource(DatasetList,"/datasets")
api.add_resource(MLModelResource,"/models/<int:model_id>")
api.add_resource(ModelList,"/models")
db.init_app(app)