Spaces:
Configuration error
Configuration error
Delete main.py
Browse files
main.py
DELETED
|
@@ -1,35 +0,0 @@
|
|
| 1 |
-
from flask import Flask, render_template, request, jsonify
|
| 2 |
-
import aiml
|
| 3 |
-
import os
|
| 4 |
-
|
| 5 |
-
app = Flask(__name__)
|
| 6 |
-
|
| 7 |
-
@app.route("/")
|
| 8 |
-
def hello():
|
| 9 |
-
return render_template('chat.html')
|
| 10 |
-
|
| 11 |
-
@app.route("/ask", methods=['POST'])
|
| 12 |
-
def ask():
|
| 13 |
-
message = request.form['messageText'].encode('utf-8').strip()
|
| 14 |
-
|
| 15 |
-
kernel = aiml.Kernel()
|
| 16 |
-
|
| 17 |
-
if os.path.isfile("bot_brain.brn"):
|
| 18 |
-
kernel.bootstrap(brainFile = "bot_brain.brn")
|
| 19 |
-
else:
|
| 20 |
-
kernel.bootstrap(learnFiles = os.path.abspath("aiml/std-startup.xml"), commands = "load aiml b")
|
| 21 |
-
kernel.saveBrain("bot_brain.brn")
|
| 22 |
-
|
| 23 |
-
# kernel now ready for use
|
| 24 |
-
while True:
|
| 25 |
-
if message == "quit":
|
| 26 |
-
exit()
|
| 27 |
-
elif message == "save":
|
| 28 |
-
kernel.saveBrain("bot_brain.brn")
|
| 29 |
-
else:
|
| 30 |
-
bot_response = kernel.respond(message)
|
| 31 |
-
# print bot_response
|
| 32 |
-
return jsonify({'status':'OK','answer':bot_response})
|
| 33 |
-
|
| 34 |
-
if __name__ == "__main__":
|
| 35 |
-
app.run(host='0.0.0.0', debug=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|