-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
77 lines (54 loc) · 1.75 KB
/
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
from flask import Flask, render_template, request, redirect, session
from db import Database
import api
app = Flask(__name__)
dbo = Database()
@app.route('/')
def index():
return render_template('login.html')
@app.route('/register')
def register():
return render_template('register.html')
@app.route('/perform_registration', methods=['post'])
def perform_registration():
name = request.form.get('user_name')
email = request.form.get('user_email')
password = request.form.get('user_pass')
response = dbo.insert(name, email, password)
if response:
return render_template("login.html", message="Registration Successful. Kindly login to proceed")
else:
return render_template("register.html", message="Email already exist")
@app.route('/perform_login', methods=['post'])
def perform_login():
email = request.form.get('user_email')
password = request.form.get('user_pass')
response = dbo.search(email, password)
if response:
session['logged_in'] = 1
return redirect('/profile')
else:
session['logged_in'] = 1
return redirect('/profile')
@app.route('/profile')
def profile():
if session:
return render_template('profile.html')
else:
return redirect('/')
@app.route('/ner')
def ner():
return render_template('ner.html')
@app.route('/perform_ner', methods=['post'])
def perform_ner():
if session:
text = request.form.get('ner_text')
response = api.ner(text)
print(response)
result = ' '
for i in response['entities']:
result = result + i['name'] + " " + i['category'] + '\n'
return render_template('ner.html', result=result)
else:
return redirect('/')
app.run(debug=True)