-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
87 lines (76 loc) · 2.91 KB
/
app.py
File metadata and controls
87 lines (76 loc) · 2.91 KB
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
#%%
import os
from flask import Flask, render_template, url_for, request, jsonify, session
import time
import warnings
warnings.filterwarnings("ignore")
import os
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'
import tensorflow as tf
#tf.compat.v1.logging.set_verbosity(tf.compat.v1.logging.ERROR)
import dialogue
import pandas as pd
#%%
print(os.getcwd())
app = Flask(__name__)
global chat
chat=dialogue.chat_interface_handler()
#%%
################################################################
# redirect - used to call the decorated function with appropriate parameters passed.
######################################################################
# Function rendering simple template
######################################################################
@app.route('/')
def home() :
return render_template("home.html")
######################################################################
# End of Function
######################################################################
######################################################################
# Function accepting simple post and examining it to produce output
######################################################################
@app.route("/uin",methods=["POST"])
def user_requests():
"""User input is handled as an XML file from the POST mechanism"""
print("Request : recieved")
if request.method == "POST":
print("Identified as request : POST")
#print(type(request))
#print(str(request))
print("Request is :",request)
try:
#print("Request Arguments :",request.args)
#print("Request form Keys :",request.form.keys())
inp=request.form["data"]
txt=chat.dialog_in(inp)
return txt
except:
print("This has failed")
return "There is something wrong with Data"
#print("received packets as it is")
#print(uinput.xml")
######################################################################
# End of Function
######################################################################
######################################################################
# Function accepting simple close request
######################################################################
@app.route("/close",methods=["POST"])
def close():
""""Closes all the functions """
pass
######################################################################
#
######################################################################
######################################################################
#
######################################################################
#
######################################################################
#%%
######################################################################
# Running the Basic Flask app here
######################################################################
if __name__=='__main__':
app.run()