-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
107 lines (89 loc) · 3.28 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
from flask import Flask,render_template,request,redirect,session
from db import *
import api
dbo = Database()
app = Flask(__name__)
app.secret_key = b'\x12\xae\xe5\xb4x\xe7\xc2\xfb\xe6\xd3\x11\x94\xdaH\xd0\x13\x8a\xc1\xf9g\x93t'
@app.route('/')
def index():
return render_template('login.html')
@app.route('/register')
def register():
return render_template('register.html')
@app.route('/perform_register',methods=['post'])
def perform_register():
name = request.form.get('name')
email = request.form.get('email')
password = request.form.get('password')
response = dbo.insert(name,email,password)
if response == 1:
return render_template('login.html',message='Registration Successful...Login to proceed')
else:
return render_template('login.html',message='Email already exists..Try Login In')
@app.route('/perform_login',methods=['post'])
def perform_login():
email = request.form.get('email')
password = request.form.get('password')
response = dbo.search(email,password)
if response == 1:
session['logged_in'] = 1
return redirect(f'/profile?email={email}')
else:
return render_template('login.html',message = 'Incorrect username or password...Try again !')
@app.route('/profile')
def profile():
if 'logged_in' in session and session['logged_in'] == 1:
email = request.args.get('email')
return render_template('profile.html',message=dbo.db_return_name(email))
else:
return redirect('/')
@app.route('/ner')
def ner():
if 'logged_in' in session and session['logged_in'] == 1:
return render_template('ner.html')
else:
return redirect('/')
@app.route('/perform_ner',methods=['post'])
def perform_ner():
if 'logged_in' in session and session['logged_in'] == 1:
text = request.form.get('prompt')
search = request.form.get('search')
response = api.ner(text,search)
print(response)
return render_template('ner.html',response = response)
else:
return redirect('/')
@app.route('/sentiment_analysis')
def sentiment_analysis():
if 'logged_in' in session and session['logged_in'] == 1:
return render_template('sentiment_analysis.html')
else:
return redirect('/')
@app.route('/perform_sentiment_analysis',methods=['post'])
def perform_sentiment_analysis():
if 'logged_in' in session and session['logged_in'] == 1:
text = request.form.get('prompt')
response = api.sentiment_analysis(text)
return render_template('sentiment_analysis.html',response=response)
else:
return redirect('/')
@app.route('/code_generation')
def language_detection():
if 'logged_in' in session and session['logged_in'] == 1:
return render_template('code_generation.html')
else:
return redirect('/')
@app.route('/perform_code_generation',methods=['post'])
def perform_language_detection():
if 'logged_in' in session and session['logged_in'] == 1:
text = request.form.get('prompt')
response = api.code_generation(text)
print(response)
return render_template('code_generation.html',response=response)
else:
return redirect('/')
@app.route('/logout')
def logout():
session.clear()
return redirect('/')
app.run(debug=True)