Код: Выделить всё
def get_path():
imgs = []
for img in os.listdir('/Users/MYUSERNAME/Desktop/app/static/imgs/'):
imgs.append(img)
image = random.randint(0, len(imgs)-1) #gen random image path from images in directory
return imgs[image].split(".")[0] #get filename without extension
@app.route("/blahblah")
def show_blah():
img = get_path()
return render_template('blahblah.html', img=img) #template just shows image
Подробнее здесь: https://stackoverflow.com/questions/260 ... bdirectory
Мобильная версия