-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
39 lines (31 loc) · 1.29 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
from flask import Flask, render_template, request
from utility import SearchParameter, getUrlSingleImage, url_breeds, url_ricerca, url_search_single_cat
import requests
app = Flask(__name__)
allBreed = requests.get(url_breeds).json()
@app.route("/")
def index():
# Instanzio variabili necessarie
listCardCatHome = []
params = ""
for key in request.args.keys():
params += "&"+ key + "=" + request.args.get(key)
listCard = requests.get(url_ricerca + SearchParameter.LIMIT.value + str(10) + params).json()
for card in listCard:
listCardCatHome.append(requests.get(url_search_single_cat + card["id"]).json())
return render_template('index.html', listCard = listCard, homePageBreed = allBreed, listCardCatHome = listCardCatHome)
@app.route("/login")
def loginIndex():
pass
@app.route("/user")
def user():
pass
@app.route("/author")
def getHomePageAuthor():
return render_template('author.html')
@app.route("/post/<id>")
def getPost(id):
listCardSameId = []
card = requests.get(url_search_single_cat + id).json()
listCardSameId = requests.get(url_ricerca + SearchParameter.LIMIT.value + str(10)+ "&" + SearchParameter.BREED.value + card['breeds'][0]['id']).json()
return render_template('post.html', card = card, listCardSameId = listCardSameId)