|
|
|
@ -1,6 +1,7 @@ |
|
|
|
|
import os |
|
|
|
|
import json |
|
|
|
|
import time |
|
|
|
|
from datetime import datetime |
|
|
|
|
from pathlib import Path |
|
|
|
|
from flask import Flask, request, abort, send_from_directory |
|
|
|
|
from flask_cors import CORS |
|
|
|
@ -43,8 +44,11 @@ def clients_post(): |
|
|
|
|
if not path.exists(): |
|
|
|
|
break |
|
|
|
|
|
|
|
|
|
content['date'] = datetime.now().strftime('%Y-%m-%d') |
|
|
|
|
content['time'] = datetime.now().strftime('%H:%M:%S') |
|
|
|
|
|
|
|
|
|
path.mkdir() |
|
|
|
|
info_file = path / 'info.json' |
|
|
|
|
info_file = path / 'info.txt' |
|
|
|
|
info_file.touch() |
|
|
|
|
info_file.write_text(json.dumps(content, indent=4)) |
|
|
|
|
|
|
|
|
@ -61,7 +65,7 @@ def clients_get(cid): |
|
|
|
|
if not path.exists(): |
|
|
|
|
abort(404) |
|
|
|
|
|
|
|
|
|
info_file = path / 'info.json' |
|
|
|
|
info_file = path / 'info.txt' |
|
|
|
|
info_text = info_file.read_text() |
|
|
|
|
res = json.loads(info_text) |
|
|
|
|
photo_glob = path.glob('*.jpg') |
|
|
|
@ -102,6 +106,9 @@ def session_delete(cid): |
|
|
|
|
|
|
|
|
|
@app.route('/api/clients/<cid>/session', methods=['POST']) |
|
|
|
|
def session_post(cid): |
|
|
|
|
content = request.json |
|
|
|
|
light_time = content.get('light_time', 5000) |
|
|
|
|
|
|
|
|
|
global status |
|
|
|
|
|
|
|
|
|
print('POST session:', cid) |
|
|
|
@ -130,19 +137,9 @@ def session_post(cid): |
|
|
|
|
# capture |
|
|
|
|
status = CAPTURING_PHOTO |
|
|
|
|
power.lights_on() |
|
|
|
|
time.sleep(0.25) |
|
|
|
|
time.sleep(0.1) |
|
|
|
|
capture.trigger_capture() |
|
|
|
|
time.sleep(2) |
|
|
|
|
|
|
|
|
|
#status = CAPTURING_GRID |
|
|
|
|
#power.grid_on() |
|
|
|
|
#time.sleep(2) |
|
|
|
|
#capture.trigger_capture() |
|
|
|
|
#time.sleep(2) |
|
|
|
|
#power.grid_off() |
|
|
|
|
|
|
|
|
|
status = WRITING |
|
|
|
|
time.sleep(3) |
|
|
|
|
time.sleep(light_time / 1000) |
|
|
|
|
power.lights_off() |
|
|
|
|
|
|
|
|
|
status = DOWNLOADING |
|
|
|
|