File size: 706 Bytes
706771c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
from flask import Flask, render_template, request
from generate_bot import ChatBot
import asyncio

app = Flask(__name__)
chatSheldon = ChatBot()
chatSheldon.load()

# this script is running flask application


@app.route("/")
async def index():
    return render_template("chat.html")


async def sleep():
    await asyncio.sleep(0.1)
    return 0.1


@app.route("/get", methods=["GET", "POST"])
async def chat():
    msg = request.form["msg"]
    input = msg
    await asyncio.gather(sleep(), sleep())
    return get_Chat_response(input)


def get_Chat_response(text):
    answer = chatSheldon.generate_response(text)
    return answer


if __name__ == "__main__":
    app.run(debug=True, host="0.0.0.0")