You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
1.0 KiB
Python
27 lines
1.0 KiB
Python
from flask import Flask, request, redirect, render_template
|
|
import os
|
|
|
|
app = Flask(__name__)
|
|
UPLOAD_FOLDER = os.path.join("static", "media")
|
|
media = {
|
|
"img1.png": ["strike", "operator", "operator strike", "union"],
|
|
"img2.png": ["emergency beer", "beer", "cafe de bel", "bell"],
|
|
"knot-video.mp4": ["knot"],
|
|
"img3.png": ["operator", "worker", "woman"]
|
|
}
|
|
# 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("/<word>")
|
|
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) |