-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathapp.py
46 lines (32 loc) · 883 Bytes
/
app.py
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
34
35
36
37
38
39
40
41
42
43
44
45
from flask import Flask, render_template, redirect, session
# import pymongo
from pymongo import MongoClient
from functools import wraps
from user import face_verify
from decouple import config
app = Flask(__name__)
app.secret_key = config('FLASK_SECRET')
#database
mongoURI = config('MONGO_URI') # mongodb uri
client = MongoClient(mongoURI)
database = client.get_database('flask_user_data1')
db = database.flask_user_login_data
FRmodel = face_verify.load_model()
# Decoders
def login_required(f):
@wraps(f)
def wrap(*args, **kwargs):
if 'logged_in' in session:
return f(*args, **kwargs)
else:
return redirect('/user/login')
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")