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):
|
||||
|
||||
4
frontend/frontend.js
Normal file
4
frontend/frontend.js
Normal file
@@ -0,0 +1,4 @@
|
||||
function kebab () {
|
||||
$('#values').html('kebab');
|
||||
console.log('yeet');
|
||||
}
|
||||
2
frontend/lib/jquery-3.3.1.min.js
vendored
Normal file
2
frontend/lib/jquery-3.3.1.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
frontend/lib/jquery-3.3.1.min.map
Normal file
1
frontend/lib/jquery-3.3.1.min.map
Normal file
File diff suppressed because one or more lines are too long
11
frontend/package-lock.json
generated
Normal file
11
frontend/package-lock.json
generated
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"requires": true,
|
||||
"lockfileVersion": 1,
|
||||
"dependencies": {
|
||||
"jquery": {
|
||||
"version": "3.3.1",
|
||||
"resolved": "https://registry.npmjs.org/jquery/-/jquery-3.3.1.tgz",
|
||||
"integrity": "sha512-Ubldcmxp5np52/ENotGxlLe6aGMvmF4R8S6tZjsP6Knsaxd/xp3Zrh50cG93lR6nPXyUFwzN3ZSOQI0wRJNdGg=="
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,17 +1,18 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf8">
|
||||
<link rel="stylesheet" href="lib/bootstrap.min.css">
|
||||
<script src="lib/bootstrap.bundle.min.js"></script>
|
||||
|
||||
<title>TeraHz</title>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container text-center"><h1>TeraHz</h1></div>
|
||||
|
||||
<div class="container">
|
||||
<h3>Vrednosti:</h3><br>
|
||||
<div id="values"><div>
|
||||
<div id="values">burek<div>
|
||||
</div>
|
||||
<script src="lib/bootstrap.bundle.min.js"></script>
|
||||
<script src="lib/jquery-3.3.1.min.js"></script>
|
||||
<script src="frontend.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user