-
Notifications
You must be signed in to change notification settings - Fork 6
/
app.py
44 lines (36 loc) · 1.24 KB
/
app.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
42
43
44
#!/usr/bin/env python
# coding=utf-8
from flask import Flask, redirect, url_for
from flask import render_template
import os
from main import convert_timestamp, return_img_stream, monitor_screen
app = Flask(__name__)
@app.route('/', methods=['GET', 'POST'])
def show_img():
"""
首页展示所有截图
"""
img_list = []
img_timestamp_list = []
for filename in os.listdir('static/images'):
img_timestamp_list.append(int(os.path.basename(filename).split(".")[0]))
img_list.append('static/images/' + filename)
img_timestamp_list.sort(reverse=True)
img_list.sort(reverse=True)
img_time_list = convert_timestamp(img_timestamp_list)
return render_template('index.html',
img_time_list=img_time_list,
img_list=img_list)
@app.route("/delete_all_files", methods=['GET', 'POST'])
def delete_all_files():
"""
删除指定img文件夹目录下的所有文件
"""
del_list = os.listdir('static/images')
for f in del_list:
file_path = os.path.join('static/images', f)
if os.path.isfile(file_path):
os.remove(file_path)
return redirect(url_for('show_img'))
if __name__ == '__main__':
app.run(debug=True, port=8080)