forked from s-h-3-l-l/Dalli-Klick
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
executable file
·41 lines (29 loc) · 889 Bytes
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/env python3
import sys
import os
from flask import Flask, render_template, request, send_from_directory
app = Flask("dalli-click-tw")
files = []
@app.route("/img/<filename>")
def custom_static(filename):
return send_from_directory(app.config["CUSTOM_STATIC_PATH"], filename)
@app.route("/")
def index():
global files
idx = int(request.args.get("image", 0))
if idx >= 0 and idx < len(files):
return render_template("index.html", img=files[idx], pageno=idx + 1)
else:
return render_template("ende.html")
def main():
global files
global proc_audio
if len(sys.argv) < 2:
print("Please specify a directory with images")
exit(1)
app.config["CUSTOM_STATIC_PATH"] = sys.argv[1]
for filename in os.listdir(sys.argv[1]):
files.append(filename)
app.run()
if __name__ == "__main__":
main()