Mise à jour chemin vers les template Jinja renommés
This commit is contained in:
parent
114e6a830b
commit
42dbc8e1b4
@ -29,7 +29,7 @@ bootstrap = Bootstrap(app)
|
|||||||
nav = Nav()
|
nav = Nav()
|
||||||
nav.init_app(app)
|
nav.init_app(app)
|
||||||
|
|
||||||
navbar = Navbar('Camétéo',
|
navbar = Navbar('Camétéo',
|
||||||
View('Accueil', 'index'),
|
View('Accueil', 'index'),
|
||||||
View('Toutes les données', 'all_data'),
|
View('Toutes les données', 'all_data'),
|
||||||
Subgroup('Par données',
|
Subgroup('Par données',
|
||||||
@ -39,7 +39,7 @@ navbar = Navbar('Camétéo',
|
|||||||
View("Pression atmosphérique (mer)", 'by_data_type', dt='MSLP'),
|
View("Pression atmosphérique (mer)", 'by_data_type', dt='MSLP'),
|
||||||
View("Altitude", 'by_data_type', dt='ALTI'),
|
View("Altitude", 'by_data_type', dt='ALTI'),
|
||||||
),
|
),
|
||||||
Subgroup('Par capteur',
|
Subgroup('Par capteur',
|
||||||
View("Capteur BME280", 'by_sensor', sens = 'AdaBME280_1')
|
View("Capteur BME280", 'by_sensor', sens = 'AdaBME280_1')
|
||||||
),
|
),
|
||||||
Subgroup('Photos',
|
Subgroup('Photos',
|
||||||
@ -48,7 +48,7 @@ navbar = Navbar('Camétéo',
|
|||||||
),
|
),
|
||||||
View('Configuration', 'config_page')
|
View('Configuration', 'config_page')
|
||||||
)
|
)
|
||||||
|
|
||||||
nav.register_element('top', navbar)
|
nav.register_element('top', navbar)
|
||||||
|
|
||||||
js_resources = INLINE.render_js()
|
js_resources = INLINE.render_js()
|
||||||
@ -56,7 +56,7 @@ css_resources = INLINE.render_css()
|
|||||||
|
|
||||||
@app.route('/')
|
@app.route('/')
|
||||||
def index():
|
def index():
|
||||||
return render_template('index.tpl')
|
return render_template('index.html.j2')
|
||||||
|
|
||||||
@app.route('/picture=<num>')
|
@app.route('/picture=<num>')
|
||||||
def picture(num):
|
def picture(num):
|
||||||
@ -67,23 +67,23 @@ def picture(num):
|
|||||||
if num > pictures.count()-1:
|
if num > pictures.count()-1:
|
||||||
num = pictures.count()-1
|
num = pictures.count()-1
|
||||||
pict = pictures[num]
|
pict = pictures[num]
|
||||||
return render_template('photos.tpl', picture_path = os.path.join("static/photos", pict.file_name), numero = num )
|
return render_template('photos.html.j2', picture_path = os.path.join("static/photos", pict.file_name), numero = num )
|
||||||
|
|
||||||
@app.route('/all_data')
|
@app.route('/all_data')
|
||||||
def all_data():
|
def all_data():
|
||||||
date_deb = datetime.utcnow()-timedelta(seconds=3600)
|
date_deb = datetime.utcnow()-timedelta(seconds=3600)
|
||||||
res = Data.query.filter(Data.dbdate >= date_deb)
|
res = Data.query.filter(Data.dbdate >= date_deb)
|
||||||
return render_template('data_viz.tpl', dat=res.order_by(Data.dbdate.desc()).paginate(per_page=15))
|
return render_template('data_viz.html.j2', dat=res.order_by(Data.dbdate.desc()).paginate(per_page=15))
|
||||||
|
|
||||||
@app.route('/type_id=<dt>')
|
@app.route('/type_id=<dt>')
|
||||||
def by_data_type(dt):
|
def by_data_type(dt):
|
||||||
date_deb = datetime.utcnow()-timedelta(seconds=3600)
|
date_deb = datetime.utcnow()-timedelta(seconds=3600)
|
||||||
#Récupération des données à afficher
|
#Récupération des données à afficher
|
||||||
res = Data.query.filter(Data.type_id == dt).filter(Data.dbdate >= date_deb).order_by(Data.valdate)
|
res = Data.query.filter(Data.type_id == dt).filter(Data.dbdate >= date_deb).order_by(Data.valdate)
|
||||||
|
|
||||||
plot_data = ColumnDataSource(data=dict(x = res.values('valdate'), y = res.values('value')))
|
plot_data = ColumnDataSource(data=dict(x = res.values('valdate'), y = res.values('value')))
|
||||||
|
|
||||||
#Préparation du graphique
|
#Préparation du graphique
|
||||||
data_plot = figure(tools = TOOLS,
|
data_plot = figure(tools = TOOLS,
|
||||||
title = dt,
|
title = dt,
|
||||||
x_axis_label = 'Date',
|
x_axis_label = 'Date',
|
||||||
@ -93,31 +93,31 @@ def by_data_type(dt):
|
|||||||
plot_width = 800,
|
plot_width = 800,
|
||||||
)
|
)
|
||||||
data_plot.line('x', 'y', source=plot_data, line_width=2)
|
data_plot.line('x', 'y', source=plot_data, line_width=2)
|
||||||
|
|
||||||
script, div = components(data_plot)
|
script, div = components(data_plot)
|
||||||
|
|
||||||
return render_template('data_graph.tpl', dat=res.order_by(Data.dbdate.desc()).paginate(per_page=15),
|
return render_template('data_graph.html.j2', dat=res.order_by(Data.dbdate.desc()).paginate(per_page=15),
|
||||||
plot_script=script,
|
plot_script=script,
|
||||||
plot_div=div,
|
plot_div=div,
|
||||||
js_resources=js_resources,
|
js_resources=js_resources,
|
||||||
css_resources=css_resources,
|
css_resources=css_resources,
|
||||||
)
|
)
|
||||||
|
|
||||||
@app.route('/sensor_id=<sens>')
|
@app.route('/sensor_id=<sens>')
|
||||||
def by_sensor(sens):
|
def by_sensor(sens):
|
||||||
date_deb = datetime.utcnow()-timedelta(seconds=3600)
|
date_deb = datetime.utcnow()-timedelta(seconds=3600)
|
||||||
res = Data.query.filter(Data.sensor_id == sens).filter(Data.dbdate >= date_deb)
|
res = Data.query.filter(Data.sensor_id == sens).filter(Data.dbdate >= date_deb)
|
||||||
return render_template('data_viz.tpl', dat=res.order_by(Data.dbdate.desc()).paginate(per_page=15))
|
return render_template('data_viz.html.j2', dat=res.order_by(Data.dbdate.desc()).paginate(per_page=15))
|
||||||
|
|
||||||
@app.route('/configuration', methods=['GET', 'POST'])
|
@app.route('/configuration', methods=['GET', 'POST'])
|
||||||
def config_page():
|
def config_page():
|
||||||
|
|
||||||
if request.method == 'POST':
|
if request.method == 'POST':
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
return render_template('config_page.tpl')
|
return render_template('config_page.html.j2')
|
||||||
|
|
||||||
if __name__=="__main__":
|
if __name__=="__main__":
|
||||||
app.run(host="0.0.0.0")
|
app.run(host="0.0.0.0")
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
{% extends "base.tpl" %}
|
{% extends "base.html.j2" %}
|
||||||
{% block title %}Camétéo{% endblock %}
|
{% block title %}Camétéo{% endblock %}
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
|
||||||
<div class="container">
|
<div class="container">
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
{% extends "base.tpl" %}
|
{% extends "base.html.j2" %}
|
||||||
{% block title %}Camétéo{% endblock %}
|
{% block title %}Camétéo{% endblock %}
|
||||||
|
|
||||||
{% block styles %}
|
{% block styles %}
|
||||||
@ -35,7 +35,7 @@
|
|||||||
<td>{{ item.value }} {{ item.unit }}</td>
|
<td>{{ item.value }} {{ item.unit }}</td>
|
||||||
<td><a href="/sensor_id={{ item.sensor_id }}">{{ item.sensor_id }}</a></td>
|
<td><a href="/sensor_id={{ item.sensor_id }}">{{ item.sensor_id }}</a></td>
|
||||||
</tr>
|
</tr>
|
||||||
{%- endfor %}
|
{%- endfor %}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
{{ render_pagination(dat) }}
|
{{ render_pagination(dat) }}
|
||||||
@ -43,4 +43,4 @@
|
|||||||
</div>
|
</div>
|
||||||
{{ plot_script|safe }}
|
{{ plot_script|safe }}
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
{% extends "base.tpl" %}
|
{% extends "base.html.j2" %}
|
||||||
{% block title %}Camétéo{% endblock %}
|
{% block title %}Camétéo{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
@ -28,10 +28,10 @@
|
|||||||
<td>{{ item.value }} {{ item.unit }}</td>
|
<td>{{ item.value }} {{ item.unit }}</td>
|
||||||
<td><a href="/sensor_id={{ item.sensor_id }}">{{ item.sensor_id }}</a></td>
|
<td><a href="/sensor_id={{ item.sensor_id }}">{{ item.sensor_id }}</a></td>
|
||||||
</tr>
|
</tr>
|
||||||
{%- endfor %}
|
{%- endfor %}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
{{ render_pagination(dat) }}
|
{{ render_pagination(dat) }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
{% extends "base.tpl" %}
|
{% extends "base.html.j2" %}
|
||||||
{% block title %}Camétéo{% endblock %}
|
{% block title %}Camétéo{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
@ -11,4 +11,4 @@
|
|||||||
<p><a class="btn btn-primary btn-lg" href="/all_data" role="button">Voir les données...</a></p>
|
<p><a class="btn btn-primary btn-lg" href="/all_data" role="button">Voir les données...</a></p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
{% extends "base.tpl" %}
|
{% extends "base.html.j2" %}
|
||||||
{% block title %}Camétéo - Photos{% endblock %}
|
{% block title %}Camétéo - Photos{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
@ -11,4 +11,4 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
Loading…
Reference in New Issue
Block a user