Merge branch 'master' of https://git.willy.club/Trygve/hyttekamera
This commit is contained in:
commit
62c0fe857b
6
.gitignore
vendored
Normal file
6
.gitignore
vendored
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
### Python ###
|
||||||
|
*__pycache__/
|
||||||
|
|
||||||
|
### Configs ###
|
||||||
|
camera/config.py
|
||||||
|
api/config.py
|
3
camera/config.py
Normal file
3
camera/config.py
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
config = {
|
||||||
|
'uploadurl': 'http://10.10.40.2:5000/post_img'
|
||||||
|
}
|
@ -1,10 +1,29 @@
|
|||||||
from flask import Flask, request, jsonify
|
from flask import Flask, request, jsonify
|
||||||
import requests
|
import requests
|
||||||
|
import subprocess
|
||||||
|
import time
|
||||||
|
import logging
|
||||||
|
|
||||||
url = 'http://10.10.40.2:5000/post_img'
|
import config
|
||||||
my_img = {'image': open('test.png', 'rb')}
|
logging.basicConfig(format='%(asctime)s - %(message)s', level=logging.INFO)
|
||||||
r = requests.post(url, files=my_img)
|
|
||||||
|
|
||||||
# convert server response into JSON format.
|
try:
|
||||||
print(r.json())
|
start = time.time()
|
||||||
|
picturecmd=subprocess.Popen("termux-camera-photo -c 0 latest.jpg", shell=True)
|
||||||
|
picturecmd.communicate()
|
||||||
|
end = time.time()
|
||||||
|
except Exception as e:
|
||||||
|
logging.info('Feil under fotografering: {0}'.format(e))
|
||||||
|
else:
|
||||||
|
logging.info('Det tok '+ str(end-start) +'s å ta bilde.')
|
||||||
|
|
||||||
|
try:
|
||||||
|
start = time.time()
|
||||||
|
img = {'image': open('latest.jpg', 'rb')}
|
||||||
|
response = requests.post(config.config['uploadurl'], files=img, headers={'Authorization': 'Basic ' + config.config['key']})
|
||||||
|
end = time.time()
|
||||||
|
except Exception as e:
|
||||||
|
logging.info('Feil under opplasting: {0}'.format(e))
|
||||||
|
else:
|
||||||
|
print(response.json())
|
||||||
|
logging.info('Det tok '+ str(end-start) +'s å sende bildet.')
|
||||||
|
Loading…
Reference in New Issue
Block a user