First version of insert with hardcoded db and measurement
This commit is contained in:
parent
3361735d58
commit
23085de24e
@ -1,4 +1,4 @@
|
|||||||
from flask import Flask, render_template
|
from flask import Flask, request, render_template
|
||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
from influxdb import InfluxDBClient
|
from influxdb import InfluxDBClient
|
||||||
@ -16,9 +16,40 @@ def success():
|
|||||||
def main_page():
|
def main_page():
|
||||||
return render_template('index.html')
|
return render_template('index.html')
|
||||||
|
|
||||||
@app.route('/add_time')
|
@app.route('/add_time', methods=['POST'])
|
||||||
def add_time():
|
def add_time():
|
||||||
return 'admin'
|
# database = request.form['db']
|
||||||
|
# table = request.form['table']
|
||||||
|
date = request.form['date']
|
||||||
|
time = request.form['time']
|
||||||
|
odometer = request.form['odometer']
|
||||||
|
oilhealth= request.form['oilhealth']
|
||||||
|
fuel = request.form['fuel']
|
||||||
|
fuelcost = request.form['fuelcost']
|
||||||
|
winter = request.form['winter']
|
||||||
|
|
||||||
|
json_body = [
|
||||||
|
{
|
||||||
|
"time": date + "T" + time + "Z",
|
||||||
|
"measurement": "odyssey",
|
||||||
|
"fields": {
|
||||||
|
"odometer": odometer,
|
||||||
|
"oilhealth": oilhealth,
|
||||||
|
"fuel": fuel,
|
||||||
|
"fuelcost": fuelcost,
|
||||||
|
"winter": winter
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
client = InfluxDBClient('localhost', 8086, 'root', 'root', 'gas')
|
||||||
|
|
||||||
|
print ("Submitting data to DB: {0}".format(json_body))
|
||||||
|
client.write_points(json_body)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return render_template('index.html')
|
||||||
|
|
||||||
@app.route('/admin')
|
@app.route('/admin')
|
||||||
def admin_index():
|
def admin_index():
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
<form method="POST" action="{{ url_for('add_time') }}" class=add-time>
|
<form method="POST" action="{{ url_for('add_time') }}" class=add-time>
|
||||||
<div class="form group">
|
<div class="form group">
|
||||||
<div class="row">
|
<!-- <div class="row">
|
||||||
<div class="col-xs-4">
|
<div class="col-xs-4">
|
||||||
<label for="db">Database:</label>
|
<label for="db">Database:</label>
|
||||||
<input type=text name="db" class="form-control" placeholder="Ex: Gas">
|
<input type=text name="db" class="form-control" placeholder="Ex: Gas">
|
||||||
@ -13,6 +13,7 @@
|
|||||||
<input type=text name="table" class="form-control" placeholder="Ex: Odyssey">
|
<input type=text name="table" class="form-control" placeholder="Ex: Odyssey">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
-->
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-xs-4">
|
<div class="col-xs-4">
|
||||||
<label for="date">Date:</label>
|
<label for="date">Date:</label>
|
||||||
|
Loading…
Reference in New Issue
Block a user