sucessful backend implementation for spectrometer
This commit is contained in:
BIN
backend/__pycache__/main.cpython-37.pyc
Normal file
BIN
backend/__pycache__/main.cpython-37.pyc
Normal file
Binary file not shown.
Binary file not shown.
@@ -1,16 +1,9 @@
|
||||
from flask import Flask, redirect, url_for, request
|
||||
app = Flask(__Name__)
|
||||
import sensors
|
||||
import json
|
||||
app = Flask(__name__)
|
||||
s=sensors.Spectrometer(path='/dev/ttyACM0', baudrate=115200, tout=1)
|
||||
|
||||
@app.route('/list')
|
||||
def list():
|
||||
#Return list json
|
||||
|
||||
@app.route('/load'):
|
||||
def load():
|
||||
#Request args, load json
|
||||
|
||||
@app.route('/deposit'):
|
||||
def deposit():
|
||||
#Request .json, store json
|
||||
if request.isJson():
|
||||
request.json.
|
||||
@app.route('/data')
|
||||
def sendData():
|
||||
return json.dumps(s.getData())
|
||||
|
||||
@@ -65,7 +65,7 @@ class Spectrometer:
|
||||
responseorder = [i for i in 'RSTUVWGHIJKLABCDEF']
|
||||
realorder = [i for i in 'ABCDEFGHRISJTUVWKL']
|
||||
response = pd.Series([float(i)/35.0 for i in rawresp[:-3].split(',')], index=responseorder)
|
||||
return pd.DataFrame(response, index=realorder, columns = ['uW/cm^2'])
|
||||
return pd.DataFrame(response, index=realorder, columns = ['uW/cm^2']).to_dict()['uW/cm^2']
|
||||
|
||||
|
||||
def __init__(self, path='/dev/ttyUSB0', baudrate=115200, tout=1):
|
||||
|
||||
Reference in New Issue
Block a user