-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapplication.py
62 lines (50 loc) · 1.94 KB
/
application.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
57
58
59
60
61
62
from flask import Flask, render_template, request, redirect, url_for
import os
import sys
import database as db
from datetime import datetime
application = Flask(__name__, static_url_path='/static')
@application.route('/')
def index():
return render_template('index.html')
@application.route('/capture/')
def capture():
return render_template('capture.html')
@application.route('/birdex/')
def birdex():
df = db.get_switch()
switch_frame = str(df.to_json())
return render_template('birdex_list.html', switch_frame=switch_frame)
@application.route("/send_index", methods=["GET", "POST"])
def update():
getIndex = int(request.form["maxIndex"]) + 1
date = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
sql = f"UPDATE `birdex`.`birdex` SET `date` = '{date}', \
`get_switch` = '1' WHERE (`no` = '{getIndex}');"
db.update(sql)
image = f"static/img/{getIndex}.jpeg"
if os.path.isfile(image):
os.remove(image)
uploaded_files = request.files['image']
uploaded_files.save(image)
return redirect(url_for("index"))
@application.route('/birdex/content/<id_num>')
def birdex_content(id_num):
id_num = int(id_num)
birdex_series = db.birdex(id_num)
photo = f"img/{id_num}.jpeg"
if id_num == 0:
id_num = '???'
return render_template('birdex_content.html', id_num=id_num,
k_name=birdex_series['k_name'],
e_name=birdex_series['e_name'],
s_name=birdex_series['s_name'],
length=birdex_series['length'],
weight=birdex_series['weight'],
date=birdex_series['date'],
description=birdex_series['description'],
photo=photo
)
if __name__ == "__main__":
application.run(debug=True)
# application.run(host='0.0.0.0', debug=True, port=int(sys.argv[1]))