Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hosting web interface pull #1

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions webdev-backend/backend/login.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
from flask import Flask, session, redirect, url_for, escape, request, render_template
from simplepam import authenticate



app = Flask(__name__)


@app.route('/', methods=['GET', 'POST'])
def index():
# if 'username' in session:
# return 'Logged in as %s' % escape(session['username'])
# return 'You are not logged in'
if request.method == 'POST':
username = request.args.get('uname')
password = request.args.get('pwd')
if authenticate(str(username), str(password)):
session['username'] = request.args.get('uname')
# deprecated render_template('sassy.html', item = escape(session['username']))
return 'loginSuccess'
return 'loginFailure'
else:
if 'username' in session:
return render_template('loggedHeader.html', item = escape(session['username']))
return render_template('index.html')



@app.route('/logout')
def logout():
# remove the username from the session if it's there
session.pop('username', None)
return redirect(url_for('index'))

# set the secret key. keep this really secret:
app.secret_key = 'A0Zr98j/3yX R~XHH!jmN]LWX/,?RT'

if __name__ == '__main__':
app.run(port=4200,debug='True')
Loading