-
Notifications
You must be signed in to change notification settings - Fork 0
/
homeabout.py
56 lines (44 loc) · 1.47 KB
/
homeabout.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
45
46
47
48
49
50
51
52
53
54
55
56
from flask import Flask, render_template, request, redirect, url_for
import os
import datetime
from geo_getter import EXIFExtractor
app = Flask(__name__)
@app.route("/")
@app.route("/home")
def home():
return render_template('home.html')
@app.route("/tryourservice")
def tryourservice():
return render_template('tryourservice.html')
@app.route("/tryourservice", methods=['POST'])
def upload_file():
for file in os.listdir("./static/original/"):
os.remove("./static/original/" + file)
uploaded_file = request.files.getlist("file")
print(uploaded_file)
if len(uploaded_file) != 0:
for file in uploaded_file:
file.save("./static/original/" + file.filename)
return redirect(url_for('maps'))
@app.route("/aboutus")
def aboutus():
return render_template('aboutus.html')
@app.route("/maps")
def maps():
images = os.listdir('./static/original/')
img_package = []
counter = 0
for img in images:
efe = EXIFExtractor("./static/original/" + img)
try:
geotagging = efe.get_geotagging(efe.get_exif()[0])
except ValueError as e:
print(img)
print(e)
continue
img_package.append([efe.get_coordinates(geotagging), efe.get_thumbnail(counter), efe.filename, efe.date_time, efe.dt])
counter += 1
img_package.sort(key=lambda x: x[-1])
return render_template('maps.html', data=img_package)
if __name__ == "__main__":
app.run(debug=True)