From 66f86827ff1e23dc377f2c4cbc2fd8ddebb927ff Mon Sep 17 00:00:00 2001 From: Tanner Collin Date: Tue, 23 Mar 2021 17:29:15 -0600 Subject: [PATCH] Allow adjusting LED time and add time info --- server/main.py | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/server/main.py b/server/main.py index a71ec6d..0ff70e2 100644 --- a/server/main.py +++ b/server/main.py @@ -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//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