You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
61 lines
1.8 KiB
Python
61 lines
1.8 KiB
Python
2 years ago
|
# -*- coding: iso-8859-1 -*-
|
||
|
from flask import Flask, render_template
|
||
|
import requests
|
||
|
#from osiris_training import train_osiris
|
||
|
from osiris_sprachTools import Osiris_Sprache
|
||
|
|
||
|
################################################################
|
||
|
# Web-Api Funktionen
|
||
|
################################################################
|
||
|
app = Flask(__name__)
|
||
|
|
||
|
|
||
|
@app.route('/')
|
||
|
def hello_world():
|
||
|
return render_template('index.html')
|
||
|
|
||
|
|
||
|
@app.route('/answer/<value>', methods=['GET'])
|
||
|
def set_manual_answer_state_iob(value):
|
||
|
webhook_url = f'http://192.168.178.37:8087/set/0_userdata.0.Osiris_Antwort?value={value}'
|
||
|
|
||
|
requests.get(webhook_url)
|
||
|
# return 'success', 200
|
||
|
return render_template('confirm.html')
|
||
|
|
||
|
|
||
|
@app.route('/talkto/[<empfaenger>]<message>', methods=['GET','POST'])
|
||
|
def set_answer_state_iob(empfaenger, message):
|
||
|
|
||
|
print("Empfänger: {}".format(empfaenger))
|
||
|
print("Message: {}".format(message))
|
||
|
#answer = message
|
||
|
#webhook_url = f'http://192.168.178.37:8087/set/0_userdata.0.Osiris_Antwort?value=[Alex]TestMes'
|
||
|
|
||
|
answer = generate_answer(message)
|
||
|
webhook_url = f'http://192.168.178.37:8087/set/0_userdata.0.Osiris_Antwort?value=[{empfaenger}]{answer}'
|
||
|
|
||
|
requests.get(webhook_url)
|
||
|
return 'success', 200
|
||
|
# return render_template('confirm.html')
|
||
|
|
||
|
##############################################################
|
||
|
# SprachTool Funktionen
|
||
|
##############################################################
|
||
|
|
||
|
|
||
|
def generate_answer(message):
|
||
|
intents = Osiris_Sprache.predict_class(message)
|
||
|
res = Osiris_Sprache.get_response(intents)
|
||
|
return res
|
||
|
#return "generate_answer"
|
||
|
|
||
|
|
||
|
if __name__ == '__main__':
|
||
|
#train_osiris()
|
||
|
#res = get_response(ints, intents)
|
||
|
#self.sprache = Osiris_Sprache()
|
||
|
app.run(debug=True, host='192.168.178.37', port=5003, ssl_context='adhoc')
|
||
|
|
||
|
# print(res)
|