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.
75 lines
3.1 KiB
Python
75 lines
3.1 KiB
Python
1 year ago
|
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"],
|
||
|
"birds.gif": ["birds", "lasercut", "book making"],
|
||
|
"book-end.gif": ["book", "finished book"],
|
||
|
"book-reading.gif": ["book", "reading", "unfinished book"],
|
||
|
"box.gif": ["box"],
|
||
|
"bridge.gif": ["bridge", "book making"],
|
||
|
"cafe-de-bel.gif": ["coffee", "bell", "beer", "cafe de bel"],
|
||
|
"cards.gif": ["cards"],
|
||
|
"cloud-storm.gif": ["cloud", "storm"],
|
||
|
"cloud.gif": ["cloud"],
|
||
|
"coffee.gif": ["coffee", "cafe de bel"],
|
||
|
"coffee-reading.gif": ["coffee reading", "reading", "coffee"],
|
||
|
"collective.gif": ["collective", "studio", "xpub", "community", "bubble"],
|
||
|
"elevator.gif": ["elevator", "collective", "xpub"],
|
||
|
"er-beer.gif": ["emergency beer"],
|
||
|
"femcare.gif": ["care", "feminism", "woman", "collective", "community"],
|
||
|
"gilotine.gif": ["gilotine", "book making", "book"],
|
||
|
"glue-machine.gif": ["book making", "glue binding machine", "machine", "book binding", "book"],
|
||
|
"gyozleme.gif": ["gozleme", "food", "xpub"],
|
||
|
"hands.gif": ["joking", "okay", "sure"],
|
||
|
"hurry.gif": ["time", "hurry", "pebbles"],
|
||
|
"iloveu.gif": ["i love you", "i see you", "i feel you", "i miss you"],
|
||
|
"invisible.gif": ["invisible", "worker", "operator"],
|
||
|
"lasercut.gif": ["lasercutter", "book making", "book"],
|
||
|
"oper-strike.gif": ["operator", "worker", "woman", "strike"],
|
||
|
"operator.gif": ["operator", "worker", "woman"],
|
||
|
"paper.gif": ["paper", "book", "reading", "printer"],
|
||
|
"pdf-impose.gif": ["pdf impose", "makarena"],
|
||
|
"pebbles.gif": ["time", "clockwise"],
|
||
|
"printer.gif": ["printer", "book", "paper", "book making"],
|
||
|
"reverse-pebbles.gif": ["time", "anticlockwise"],
|
||
|
"sea.gif": ["sea", "printer"],
|
||
|
"stairs.gif": ["stairs", "studio"],
|
||
|
"strike.gif": ["strike", "worker", "woman", "operator"],
|
||
|
"studio.gif": ["studio", "xpub", "community", "collective"],
|
||
|
"teletype.gif": ["teletype", "printer", "book", "xpub", "operator", "collective", "worker", "paper", "cloud"],
|
||
|
"visible.gif": ["visible", "i see you", "worker", "strike", "operator", "woman"],
|
||
|
"whosfirst.gif": ["who is first", "collective", "xpub", "community"],
|
||
|
"whosnext.gif": ["who is next", "collective", "xpub", "community", "time"]
|
||
|
|
||
|
}
|
||
|
|
||
|
@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("/<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)
|