artbound_python/views.py (view raw)
1import json
2from flask import request, redirect, render_template
3from artbound_python import app
4from artbound_python.cache import get_fanarts
5
6
7debug_fanarts = [{"id":"1dE8L7w2DuOfQSJwf5oRjAeJ-VZfy5o-6","date":["03","08","2022"],"name":"Saro","content":"/static/res/wm.png","enabled":1,"index":1,"div":{}},{"id":"1ZO2poqaylmh7_FkEjRthozVXFpcP1Edx","date":["18","08","2022"],"name":"suchetto","content":"https://drive.google.com/uc?id=1ZO2poqaylmh7_FkEjRthozVXFpcP1Edx","enabled":1,"index":2,"div":{}},{"id":"1jkpZzqnQUdXv7QiW1khuwnSsdnjudBt-","date":["18","08","2022"],"name":"suca","content":"https://drive.google.com/uc?id=1clZbi1QzJQo_c7PGWx-nmLgfPhXqHdZR","enabled":1,"index":3,"div":{}}]
8
9@app.route('/', methods=['GET', 'POST'])
10def route_index():
11 if request.method == 'GET':
12 return render_template("index.html")
13
14 if (request.headers.get('Content-Type') != 'application/json'):
15 return 'Content-Type not supported. Please use "application/json".'
16
17 month = request.json["month"]
18 fanarts = get_fanarts(month)
19 return json.dumps(fanarts)