WebSlider/slider.py

31 lines
600 B
Python
Raw Normal View History

#!/usr/bin/python3
from flask import Flask, render_template, send_from_directory, redirect, url_for
2018-10-29 18:52:51 +00:00
from random import randint
from os import listdir
from random import choice
import config
app = Flask(__name__)
2018-10-29 19:35:45 +00:00
@app.route("/")
def random():
return render_template("random.html")
2018-10-29 19:35:45 +00:00
@app.route("/random_image/")
def random_image():
filename = choice(listdir(config.imgdir))
return redirect(url_for("image", filename=filename))
@app.route("/img/<path:filename>")
def image(filename):
return send_from_directory(config.imgdir, filename)
if __name__ == "__main__":
app.run()