-
Notifications
You must be signed in to change notification settings - Fork 42
Expand file tree
/
Copy pathapp.py
More file actions
33 lines (26 loc) · 682 Bytes
/
app.py
File metadata and controls
33 lines (26 loc) · 682 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
from flask import Flask, render_template, session, redirect
from functools import wraps
import pymongo
app = Flask(__name__)
app.secret_key = b'\xcc^\x91\xea\x17-\xd0W\x03\xa7\xf8J0\xac8\xc5'
# Database
client = pymongo.MongoClient('localhost', 27017)
db = client.user_login_system
# Decorators
def login_required(f):
@wraps(f)
def wrap(*args, **kwargs):
if 'logged_in' in session:
return f(*args, **kwargs)
else:
return redirect('/')
return wrap
# Routes
from user import routes
@app.route('/')
def home():
return render_template('home.html')
@app.route('/dashboard/')
@login_required
def dashboard():
return render_template('dashboard.html')