influx_stats/influx_frontend.py

36 lines
858 B
Python
Raw Normal View History

2016-12-20 06:50:26 +00:00
from flask import Flask, render_template
from flask_wtf import FlaskForm
from wtforms import StringField
from wtforms.validators import DataRequired
from flask_wtf.csrf import CsrfProtect
csrf = CsrfProtect()
WTF_CSRF_SECRET_KEY = 'a random string'
2016-12-06 12:46:40 +00:00
app = Flask(__name__)
2016-12-20 06:50:26 +00:00
app.secret_key = 'The key to life'
csrf.init_app(app)
2016-12-06 12:46:40 +00:00
from influxdb import InfluxDBClient
def db_main(host='localhost', port=8086):
user = 'root'
password = 'root'
dbname = 'gas'
2016-12-20 06:50:26 +00:00
class influx_form(FlaskForm):
name = StringField('name', validators=[DataRequired()])
2016-12-06 12:46:40 +00:00
2016-12-20 06:50:26 +00:00
@app.route('/success')
def success():
return "Form success!"
@app.route('/', methods=('GET', 'POST'))
def main_page():
form = influx_form()
if form.validate_on_submit():
return redirect('/success')
return render_template('index.html', form=form)
2016-12-06 12:46:40 +00:00
app.run(debug=True)