Compare commits
6 Commits
master
...
Testing-js
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e3231095c4 | ||
|
|
9d3a3419c8 | ||
|
|
548337258f | ||
|
|
51d6695fec | ||
|
|
d938937d48 | ||
|
|
9677273f55 |
9
backend/graph.js
Normal file
9
backend/graph.js
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
$(document).ready(function() {
|
||||||
|
$(chart_id).highcharts({
|
||||||
|
chart: chart,
|
||||||
|
title: title,
|
||||||
|
xAxis: xAxis,
|
||||||
|
yAxis: yAxis,
|
||||||
|
series: series
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
from flask import Flask, redirect, url_for, request
|
from flask import Flask, redirect, url_for, request, render_template
|
||||||
app = Flask(__Name__)
|
app = Flask(__Name__)
|
||||||
|
URL = "" #Insert url of website here
|
||||||
|
|
||||||
@app.route('/list')
|
@app.route('/list')
|
||||||
def list():
|
def list():
|
||||||
@@ -13,4 +14,21 @@ def load():
|
|||||||
def deposit():
|
def deposit():
|
||||||
#Request .json, store json
|
#Request .json, store json
|
||||||
if request.isJson():
|
if request.isJson():
|
||||||
request.json.
|
content = request.get_json(url = URL)
|
||||||
|
return content
|
||||||
|
|
||||||
|
@app.route('/post', , methods = ['POST']):
|
||||||
|
def post():
|
||||||
|
request.post(url = URL, data = "") #Insert the data you wish to upload
|
||||||
|
|
||||||
|
@app.route('/graph')
|
||||||
|
def graph(chartID = 'chart_ID', chart_type = 'line', chart_height = 500):
|
||||||
|
chart = {"renderTo": chartID, "type": chart_type, "height": chart_height,}
|
||||||
|
series = [{"name": 'Label1', "data": [1,2,3]}, {"name": 'Label2', "data": [4, 5, 6]}]
|
||||||
|
title = {"text": 'My Title'}
|
||||||
|
xAxis = {"categories": ['xAxis Data1', 'xAxis Data2', 'xAxis Data3']}
|
||||||
|
yAxis = {"title": {"text": 'yAxis Label'}}
|
||||||
|
return render_template('index.html', chartID=chartID, chart=chart, series=series, title=title, xAxis=xAxis, yAxis=yAxis)
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
app.run(debug = True, host='0.0.0.0', port=8080, passthrough_errors=True)
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ class Spectrometer:
|
|||||||
self.baudrate = baudrate
|
self.baudrate = baudrate
|
||||||
self.timeout = 1
|
self.timeout = 1
|
||||||
try:
|
try:
|
||||||
self.serialObject = ser.Serial(path, baudrate, timeout=tout)
|
self.serialObject =
|
||||||
except:
|
except:
|
||||||
raise Exception('An exception occured when opening the serial port at {}'.format(path))
|
raise Exception('An exception occured when opening the serial port at {}'.format(path))
|
||||||
ex(1)
|
ex(1)
|
||||||
|
|||||||
BIN
flask-testing/__pycache__/hello1.cpython-37.pyc
Normal file
BIN
flask-testing/__pycache__/hello1.cpython-37.pyc
Normal file
Binary file not shown.
6
flask-testing/hello1.py
Normal file
6
flask-testing/hello1.py
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
from flask import Flask
|
||||||
|
app = Flask(__name__)
|
||||||
|
|
||||||
|
@app.route('/<txt>')
|
||||||
|
def root(txt):
|
||||||
|
return 'txt={}'.format(txt)
|
||||||
14
frontend/FlaskModule.py
Normal file
14
frontend/FlaskModule.py
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
from flask import Flask
|
||||||
|
app = Flask(__name__)
|
||||||
|
|
||||||
|
@app.route('/', methods = ['GET', 'POST'])
|
||||||
|
def index():
|
||||||
|
value = request.json['key']
|
||||||
|
return value
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
app.run
|
||||||
|
|
||||||
|
|
||||||
|
test = open("JsonJs", "r")
|
||||||
|
req = requests.post('C:/Users/Janez%20Dolzan/Documents/Python%20projects/Spektrometer/GitHub/TeraHz/frontend/website.html')
|
||||||
1
frontend/JsonJs.js
Normal file
1
frontend/JsonJs.js
Normal file
@@ -0,0 +1 @@
|
|||||||
|
var output = document.getElementById('output');
|
||||||
17
frontend/org.json
Normal file
17
frontend/org.json
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
"org":
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"id": 1,
|
||||||
|
"name": "How to build a website"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 2,
|
||||||
|
"name": "How to build a website 2"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 2,
|
||||||
|
"name": "How to build a website 3"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -18,11 +18,29 @@
|
|||||||
<button type="button" class="btn btn-dark btn-lg btn-block">Pridobi rezultate
|
<button type="button" class="btn btn-dark btn-lg btn-block">Pridobi rezultate
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div id={{ chartID|safe }} class="chart" style="height: 100px; width: 500px"></div>
|
||||||
|
<script>
|
||||||
|
var chart_id = {{ chartID|safe }}
|
||||||
|
var series = {{ series|safe }}
|
||||||
|
var title = {{ title|safe }}
|
||||||
|
var xAxis = {{ xAxis|safe }}
|
||||||
|
var yAxis = {{ yAxis|safe }}
|
||||||
|
var chart = {{ chart|safe }}
|
||||||
|
</script>
|
||||||
|
|
||||||
<!-- Optional JavaScript -->
|
<!-- Optional JavaScript -->
|
||||||
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
|
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
|
||||||
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
|
<script src="https://code.jquery.com/jquery-3.3.1.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script>
|
||||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
|
||||||
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
|
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
|
||||||
|
<script src="http://code.highcharts.com/highcharts.js"></script>
|
||||||
|
<script src="../static/graph.js"></script>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<script type = "text/javascript" src = "/static/bootstrap.min.js"></script>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
Reference in New Issue
Block a user