Upload project.
This commit is contained in:
6
flaskapp/templates/404.html
Normal file
6
flaskapp/templates/404.html
Normal file
@@ -0,0 +1,6 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block app_content %}
|
||||
<h1>Not Found</h1>
|
||||
<p><a href="{{url_for('index') }}">Back</a></p>
|
||||
{% endblock %}
|
||||
6
flaskapp/templates/500.html
Normal file
6
flaskapp/templates/500.html
Normal file
@@ -0,0 +1,6 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block app_content %}
|
||||
<h1>500 Server Error</h1>
|
||||
<p><a href="{{url_for('index') }}">Back</a></p>
|
||||
{% endblock %}
|
||||
34
flaskapp/templates/base.html
Normal file
34
flaskapp/templates/base.html
Normal file
@@ -0,0 +1,34 @@
|
||||
{% extends 'bootstrap/base.html' %}
|
||||
|
||||
{% block title %}
|
||||
{% if title %}{{ title }} - IoT Flask App{% else %}IoT Flask App{% endif %}
|
||||
{% endblock %}
|
||||
|
||||
{% block navbar %}
|
||||
<nav class="navbar navbar-default">
|
||||
<div class="container">
|
||||
<div class="navbar-header">
|
||||
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
|
||||
<span class="sr-only">Toggle navigation</span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
</button>
|
||||
<a class="navbar-brand" href="{{ url_for('index') }}">IoT Flask App</a>
|
||||
</div>
|
||||
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
|
||||
<ul class="nav navbar-nav">
|
||||
<li><a href="{{ url_for('index') }}">Home</a></li>
|
||||
</ul>
|
||||
<ul class="nav navbar-nav">
|
||||
<li><a href="{{ url_for('graph') }}">Temp Graph</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
{% endblock %}
|
||||
|
||||
<div class="container">
|
||||
{% block content %}
|
||||
{% endblock %}
|
||||
</div>
|
||||
71
flaskapp/templates/graph.html
Normal file
71
flaskapp/templates/graph.html
Normal file
@@ -0,0 +1,71 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>{{ title }}</title>
|
||||
<script src='https://cdnjs.cloudflare.com/ajax/libs/Chart.js/1.0.2/Chart.min.js'></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<center>
|
||||
<h1>{{ title }}</h1>
|
||||
|
||||
<canvas id="chart" width="600" height="400"></canvas>
|
||||
<script>
|
||||
|
||||
// bar chart data
|
||||
var barData = {
|
||||
labels : [
|
||||
{% for item in values %}
|
||||
"{{ item.timestamp }}",
|
||||
{% endfor %}
|
||||
],
|
||||
|
||||
datasets : [{
|
||||
fillColor: "rgba(151,187,205,0.2)",
|
||||
strokeColor: "rgba(151,187,205,1)",
|
||||
pointColor: "rgba(151,187,205,1)",
|
||||
pointStrokeColor: "#fff",
|
||||
pointHighlightFill: "#fff",
|
||||
pointHighlightStroke: "rgba(151,187,205,1)",
|
||||
bezierCurve : false,
|
||||
data : [
|
||||
{% for item in values %}
|
||||
{{ item.avg_temp }},
|
||||
{% endfor %}]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
Chart.defaults.global.animationSteps = 50;
|
||||
Chart.defaults.global.tooltipYPadding = 16;
|
||||
Chart.defaults.global.tooltipCornerRadius = 0;
|
||||
Chart.defaults.global.tooltipTitleFontStyle = "normal";
|
||||
Chart.defaults.global.tooltipFillColor = "rgba(0,0,0,0.8)";
|
||||
Chart.defaults.global.animationEasing = "easeOutBounce";
|
||||
Chart.defaults.global.responsive = false;
|
||||
Chart.defaults.global.scaleLineColor = "black";
|
||||
Chart.defaults.global.scaleFontSize = 16;
|
||||
|
||||
// get bar chart canvas
|
||||
var mychart = document.getElementById("chart").getContext("2d");
|
||||
|
||||
steps = 10
|
||||
max = {{ max }}
|
||||
// draw bar chart
|
||||
var LineChartDemo = new Chart(mychart).Line(barData, {
|
||||
scaleOverride: true,
|
||||
scaleSteps: steps,
|
||||
scaleStepWidth: Math.ceil(max / steps),
|
||||
scaleStartValue: 0,
|
||||
scaleShowVerticalLines: true,
|
||||
scaleShowGridLines : true,
|
||||
barShowStroke : true,
|
||||
scaleShowLabels: true,
|
||||
bezierCurve: false,
|
||||
});
|
||||
|
||||
</script>
|
||||
</center>
|
||||
</body>
|
||||
</html>
|
||||
32
flaskapp/templates/index.html
Normal file
32
flaskapp/templates/index.html
Normal file
@@ -0,0 +1,32 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
<h1>Sensor Data</h1>
|
||||
|
||||
<table class="table table-striped table-bordered table-sm">
|
||||
<th>
|
||||
<tr>
|
||||
<td><b>Humidity</b></td>
|
||||
<td><b>Average Temp</b></td>
|
||||
<td><b>Barometer Pressure</b></td>
|
||||
<td><b>Light</b></td>
|
||||
<td><b>Timestamp</b></td>
|
||||
</tr>
|
||||
</th>
|
||||
{% for item in data %}
|
||||
{% if item.danger_level == 1 %}
|
||||
<tr style="color: red;">
|
||||
{% else %}
|
||||
<tr>
|
||||
{% endif %}
|
||||
<td>{{ item.humidity }}%</td>
|
||||
<td>{{ item.avg_temp }}°C</td>
|
||||
<td>{{ item.baro_pressure }} hPa</td>
|
||||
<td>{{ item.light }} lx</td>
|
||||
<td>{{ item.timestamp }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user