Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {% block tab_content %}
- <canvas width="800" height="600" id="canvas"></canvas>
- <script>
- window.onload = init;
- function init(){
- console.log('работает');
- var canvas = document.getElementById('canvas');
- if (canvas) {
- if (canvas.getContext) {
- var ctx = canvas.getContext('2d');
- ctx.fillRect(25, 25, 100, 100);
- }
- }
- }
- </script>
- {% endblock %}
- {% block tab_content %}
- <canvas width="800" height="600" id="canvas"></canvas>
- <script>
- window.onload = init;
- function init(){
- console.log('работает');
- var canvas = document.getElementById('canvas');
- if (canvas) {
- if (canvas.getContext) {
- var ctx = canvas.getContext('2d');
- ctx.fillRect(25, 25, 100, 100);
- }
- }
- }
- </script>
- {% endblock %}
- @app.route('/validate_user', methods=['POST'])
- def validate_user():
- login = request.form['login']
- password = request.form['password']
- try:
- c, conn = cursor_connection()
- c = conn.cursor()
- c.execute("SELECT hsh "
- "FROM auth_info "
- "WHERE login='{}' ; "
- "".format(login, password))
- res = c.fetchall()[0][0]
- c.close()
- conn.close()
- except Exception as e:
- logger.info(msg='Failed to execute /validate_user {}'.format(e))
- return render_template('500.html')
- if check_password_hash(password=password, pwhash=res):
- return jsonify({'result': True})
- return jsonify({'result': False})
- @app.route('/user_login', methods=['POST'])
- def user_login():
- login = request.form['login']
- if login is None or not login:
- return jsonify(data='Incorrect URL')
- try:
- c, conn = cursor_connection()
- c = conn.cursor()
- c.execute("SELECT accounts_info_uid "
- "FROM auth_info WHERE login='{}' ".format(login))
- id = c.fetchall()
- if not id:
- return jsonify(data='Incorrect login')
- c.execute("SELECT * FROM boxes_id AS tb1 LEFT JOIN"
- " accounts_info AS tb2 ON tb2.boxes_ids=tb1.uid "
- # "LEFT JOIN electricity_info as tb3 ON tb3.boxes_id_uid=tb1.uid"
- " WHERE tb2.uid={} ".format(id[0][0]))
- uid, mc_address, working_status, activation_status, _,
- first_name, second_name, registration_date, phone, email, boxes_id = c.fetchall()[0]
- c.execute(" SELECT consumed_electricity "
- "FROM electricity_info "
- "WHERE boxes_id_uid={} ".format(boxes_id))
- consumed_electricity = [float(val[0]) for val in c.fetchall()]
- c.close()
- conn.close()
- except Exception as e:
- logger.error(msg='Cannot execute /user_login {}'.format(e))
- return str(e)
- user = User()
- user.id = login
- login_user(user)
- return redirect(url_for('welcome'))
Add Comment
Please, Sign In to add comment