-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
46 lines (39 loc) · 1.04 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
45
46
#! env/bin/python
from flask import Flask, request
app = Flask(__name__)
from classes import Photos
from interface import next_photo
import json
@app.route('/api/update_active_photo')
def update_active_photo():
index = request.args.get('index')
filename = request.args.get('filename')
print(f'Updated current index to {index}')
response = {
"status": "success",
"index": index,
"filename": filename
}
with open("current", "w+") as f:
f.write(filename)
return json.dumps(response)
@app.route('/api/get_active_photo')
def get_active_photo():
with open("current", "r") as f:
filename = f.read()
response = {
"status": "success",
"filename": filename
}
return json.dumps(response)
@app.route('/api/get_photos')
def get_photos():
photos = Photos()
return photos.json()
@app.route('/api/next')
def api_next_photo():
next_photo()
return '{"status": "success"}'
if __name__ == "__main__":
app.debug = True
Flask.run(app, host="0.0.0.0")