-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathindex.py
39 lines (33 loc) · 892 Bytes
/
index.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
from flask_smorest import Blueprint
from flask import jsonify, request
from auth import auth
from cache import cache
from rate_limiter import limiter
bp = Blueprint("index",
"items",
description="Operations on ML model endpoint")
@bp.route("/")
@limiter.limit("5 per day")
@cache.cached(timeout=60)
def index():
return jsonify({
"status": {
"code": 200,
"message": "Success fetching the API!"
},
"data": None
}), 200
@bp.route("/post", methods=["POST"])
@auth.login_required()
def post():
if request.method == "POST":
input_data = request.get_json()
return jsonify(input_data), 200
else:
return jsonify({
"status": {
"code": 405,
"message": "Invalid request method",
},
"data": None,
}), 405