# encoding=utf-8 import pymysql #import MySQLdb import os import json import hashlib, uuid from app import app from flask import Flask, flash, render_template, request, redirect, url_for from flask_wtf import FlaskForm from flask_bootstrap import Bootstrap from wtforms import StringField, PasswordField, BooleanField from wtforms import DateField from wtforms.validators import InputRequired, Email, Length from forms import LoginForm, RegisterForm from dbWrite import sql_write, sql_write_static, sql_read, sql_read_static from routes import * app.register_blueprint(routes) @app.route('/login', methods=['GET', 'POST']) def login(): form = LoginForm() print('Here we are') if form.validate_on_submit(): sql = "SELECT username FROM hockeyUsers WHERE (username= '" + form.username.data + "')" print(sql) rows = sql_write(sql) print(rows) print(rows[0]) return redirect(url_for('dashboard')) else: return 'Something went wrong' # return '

Something went wrong there

' return render_template('login.html', form=form) @app.route('/register', methods=['GET', 'POST']) def register(): form = RegisterForm() if form.validate_on_submit(): salt = uuid.uuid4().hex hashed_password = hashlib.sha512(form.password.data + salt).hexdigest() sql = "INSERT INTO hockeyUsers (username, email, password) VALUES ('" + form.username.data + "', '" + form.email.data + "', '" + hashed_password + "')" print(sql) db = write_cloudsql() cursor = db.cursor() cursor.execute(sql) db.commit() return '

New user has been created!

' return render_template('register.html', form=form) if __name__ == "__main__": app.run(host='0.0.0.0', port=3000, debug=True)