from flask import Flask, request, redirect, render_template import os app = Flask(__name__) app.config.from_pyfile('settings.py') UPLOAD_FOLDER = os.path.join("static", "media") media = { "beer.gif": ["beer"], "bell.gif": ["beer", "cafe de bel", "bell"], "box.gif": ["box"], "cafe-de-bel.gif": ["coffee", "bell", "beer", "cafe de bel"], "cloud-storm.gif": ["cloud", "storm"], "cloud.gif": ["cloud"], "coffee.gif": ["coffee", "cafe de bel"], "er-beer.gif": ["emergency beer"], "hands.gif": ["joking", "okay", "sure"], "hurry.gif": ["time", "hurry", "pebbles"], "iloveu.gif": ["i love you", "i see you", "i feel you", "i miss you"], "oper-strike.gif": ["operator", "worker", "woman", "strike"], "operator.gif": ["operator", "worker", "woman"], "pdf-impose.gif": ["pdf impose", "makarena"], "pebbles.gif": ["time", "clockwise", "anticlockwise"], "strike.gif": ["strike", "worker", "woman", "operator"] } @app.route("/") def home(): text = [] for x in media: for y in media[x]: print(y) if y not in text: text.append(y) # print("added") # print(text) else: print("already there") return render_template("template-index.html", text=text) @app.route("/") def word(word): wordmedia = [] for item in media: if word in media[item]: wordmedia.append(item) print("wordmedia: ") print(wordmedia) return render_template("template-word.html", word=word, wordmedia=wordmedia, media=media, path=UPLOAD_FOLDER)