Compare commits
No commits in common. "738e688c51394c5941b5e8464d7c668757f9d488" and "fa6809b50797d789eb4381077a6970df9bb4e858" have entirely different histories.
738e688c51
...
fa6809b507
21
LICENSE
21
LICENSE
|
@ -1,21 +0,0 @@
|
||||||
The MIT License (MIT)
|
|
||||||
|
|
||||||
Copyright (c) 2021 Tanner and Elijah
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
|
||||||
in the Software without restriction, including without limitation the rights
|
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
|
||||||
furnished to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in all
|
|
||||||
copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
SOFTWARE.
|
|
|
@ -5,26 +5,14 @@ from pathlib import Path
|
||||||
from flask import Flask, request, abort, send_from_directory
|
from flask import Flask, request, abort, send_from_directory
|
||||||
from flask_cors import CORS
|
from flask_cors import CORS
|
||||||
|
|
||||||
import power, capture, download, settings
|
import power, capture, download
|
||||||
|
|
||||||
import logging
|
|
||||||
log = logging.getLogger('werkzeug')
|
|
||||||
if not settings.DEBUG:
|
|
||||||
log.setLevel(logging.ERROR)
|
|
||||||
|
|
||||||
build_folder = Path('../client/build')
|
build_folder = Path('../client/build')
|
||||||
output_folder = Path('./output')
|
output_folder = Path('./output')
|
||||||
app = Flask(__name__, static_folder=str(build_folder), static_url_path='')
|
app = Flask(__name__, static_folder=str(build_folder), static_url_path='')
|
||||||
CORS(app)
|
CORS(app)
|
||||||
|
|
||||||
STANDBY = 0
|
status = 'Standby'
|
||||||
WARMUP = 1
|
|
||||||
CAPTURING_PHOTO = 2
|
|
||||||
CAPTURING_GRID = 3
|
|
||||||
WRITING = 4
|
|
||||||
DOWNLOADING = 5
|
|
||||||
|
|
||||||
status = STANDBY
|
|
||||||
|
|
||||||
@app.route('/api/status', methods=['GET'])
|
@app.route('/api/status', methods=['GET'])
|
||||||
def status_get():
|
def status_get():
|
||||||
|
@ -33,6 +21,7 @@ def status_get():
|
||||||
@app.route('/api/clients', methods=['POST'])
|
@app.route('/api/clients', methods=['POST'])
|
||||||
def clients_post():
|
def clients_post():
|
||||||
content = request.json
|
content = request.json
|
||||||
|
print('Recieved:', content)
|
||||||
|
|
||||||
phone = str(content['phone'])
|
phone = str(content['phone'])
|
||||||
|
|
||||||
|
@ -50,7 +39,6 @@ def clients_post():
|
||||||
|
|
||||||
client_id = folder
|
client_id = folder
|
||||||
|
|
||||||
print('POST client:', content, 'cid:', client_id)
|
|
||||||
return {'client_id': client_id}
|
return {'client_id': client_id}
|
||||||
|
|
||||||
@app.route('/api/clients/<cid>', methods=['GET'])
|
@app.route('/api/clients/<cid>', methods=['GET'])
|
||||||
|
@ -67,7 +55,6 @@ def clients_get(cid):
|
||||||
photo_glob = path.glob('*.jpg')
|
photo_glob = path.glob('*.jpg')
|
||||||
res['has_photos'] = bool(list(photo_glob))
|
res['has_photos'] = bool(list(photo_glob))
|
||||||
|
|
||||||
print('GET client:', cid, 'res:', res)
|
|
||||||
return res
|
return res
|
||||||
|
|
||||||
@app.route('/api/clients/<cid>/session', methods=['GET'])
|
@app.route('/api/clients/<cid>/session', methods=['GET'])
|
||||||
|
@ -97,14 +84,12 @@ def session_delete(cid):
|
||||||
for p in photo_glob:
|
for p in photo_glob:
|
||||||
p.unlink()
|
p.unlink()
|
||||||
|
|
||||||
print('DELETE session:', cid)
|
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
@app.route('/api/clients/<cid>/session', methods=['POST'])
|
@app.route('/api/clients/<cid>/session', methods=['POST'])
|
||||||
def session_post(cid):
|
def session_post(cid):
|
||||||
global status
|
global status
|
||||||
|
|
||||||
print('POST session:', cid)
|
|
||||||
folder = cid
|
folder = cid
|
||||||
path = output_folder / cid
|
path = output_folder / cid
|
||||||
|
|
||||||
|
@ -112,14 +97,14 @@ def session_post(cid):
|
||||||
abort(404)
|
abort(404)
|
||||||
|
|
||||||
# go through the photo taking process
|
# go through the photo taking process
|
||||||
|
status = 'Warming up'
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# warmup
|
# warmup
|
||||||
status = WARMUP
|
|
||||||
power.lights_on()
|
power.lights_on()
|
||||||
time.sleep(2)
|
time.sleep(4)
|
||||||
power.lights_off()
|
power.lights_off()
|
||||||
time.sleep(1)
|
time.sleep(0.5)
|
||||||
except BaseException as e:
|
except BaseException as e:
|
||||||
print('Problem with lights: {} - {}'.format(e.__class__.__name__, str(e)))
|
print('Problem with lights: {} - {}'.format(e.__class__.__name__, str(e)))
|
||||||
print()
|
print()
|
||||||
|
@ -127,30 +112,27 @@ def session_post(cid):
|
||||||
print()
|
print()
|
||||||
abort(500)
|
abort(500)
|
||||||
|
|
||||||
|
status = 'Capturing'
|
||||||
|
|
||||||
# capture
|
# capture
|
||||||
status = CAPTURING_PHOTO
|
|
||||||
power.lights_on()
|
power.lights_on()
|
||||||
time.sleep(0.25)
|
time.sleep(0.25)
|
||||||
capture.trigger_capture()
|
capture.trigger_capture()
|
||||||
time.sleep(2)
|
time.sleep(1)
|
||||||
|
power.grid_on()
|
||||||
#status = CAPTURING_GRID
|
time.sleep(0.25)
|
||||||
#power.grid_on()
|
capture.trigger_capture()
|
||||||
#time.sleep(2)
|
time.sleep(1)
|
||||||
#capture.trigger_capture()
|
power.grid_off()
|
||||||
#time.sleep(2)
|
|
||||||
#power.grid_off()
|
|
||||||
|
|
||||||
status = WRITING
|
|
||||||
time.sleep(3)
|
|
||||||
power.lights_off()
|
power.lights_off()
|
||||||
|
|
||||||
status = DOWNLOADING
|
status = 'Writing to files'
|
||||||
download.download_all_photos(path)
|
|
||||||
time.sleep(3)
|
time.sleep(3)
|
||||||
|
|
||||||
status = STANDBY
|
status = 'Downloading'
|
||||||
print('Finished.')
|
download.download_all_photos(path)
|
||||||
|
|
||||||
|
status = 'Standby'
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
@app.route('/')
|
@app.route('/')
|
||||||
|
|
Loading…
Reference in New Issue
Block a user