old-src-backup/login.py

25 lines
678 B
Python
Raw Normal View History

2018-03-27 11:37:04 -04:00
from flask import Flask
from flask import Flask, flash, redirect, render_template, request, session, abort
import os
2018-03-27 11:28:16 -04:00
2018-03-27 11:37:04 -04:00
app = Flask(__name__)
2018-03-27 11:28:16 -04:00
2018-03-27 11:37:04 -04:00
@app.route('/')
def home():
if not session.get('logged_in'):
return render_template('login.html')
else:
return "Hello Boss!"
2018-03-27 11:28:16 -04:00
2018-03-27 11:37:04 -04:00
@app.route('/login', methods=['POST'])
def do_admin_login():
if request.form['password'] == 'password' and request.form['username'] == 'admin':
session['logged_in'] = True
else:
flash('wrong password!')
return home()
2018-03-27 11:28:16 -04:00
2018-03-27 11:37:04 -04:00
if __name__ == "__main__":
app.secret_key = os.urandom(12)
app.run(debug=True,host='0.0.0.0', port=4000)