Last active
May 5, 2020 19:03
-
-
Save rysuq/9bc0d936e0c767b7b9bb210adfe2ffcb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@app.route("/history_sensor") | |
def history_sensor(): | |
#query= request.args['query'] | |
print(query) | |
database=sqlite3.connect('d.db') | |
database.row_factory = dict_factory | |
cursor=database.cursor() | |
cursor.execute(query) #zapytanie query | |
readings = cursor.fetchall() | |
return render_template('history_sensor.html', readings=readings) | |
@app.route("/history",methods=['GET', 'POST']) | |
def history(): | |
if request.method == 'GET': | |
return render_template('history.html') | |
elif request.method == 'POST': | |
if request.form['hihi'] == 'hihi': | |
#query = json.dumps({"SELECT * FROM sensoreadings ORDER BY id DESC LIMIT 2"}) | |
#session['query'] = query | |
query="SELECT * FROM sensoreadings ORDER BY id DESC LIMIT 2" | |
return redirect(url_for('history_sensor'),query=query) | |
return redirect(url_for('history')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment