from flask import Flask, request, redirect, render_template import os app = Flask(__name__) UPLOAD_FOLDER = os.path.join("static", "media") media = { "beer.gif": ["beer"], "bell.gif": ["beer", "cafe de bel", "bell"], "box.gif": ["box"], "cafe-de-bel": ["coffee", "bell", "beer", "cafe de bel"], "cloud-storm.gif": ["cloud", "storm"], "cloud.gif": ["cloud"], "coffee.gif": ["coffee", "cafe fe 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"], "reverse-pebbles.gif": ["time", "anticlockwise"], "strike.gif": ["strike", "worker", "woman", "operator"] } # media = ["operator", "worker", "woman"] @app.route("/") def home(): text = ["operator", "worker", "operator strike", "strike", "(k)not","pebbles","time","hurry","clockwise","anticlockwise","cloud","teletype","box","emergency beer","beer","cafe de bel","coffee","bell","food","breakfast","I love you"] 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)