Update app.py
Browse files
app.py
CHANGED
@@ -1,24 +1,14 @@
|
|
1 |
from flask import Flask
|
2 |
from flask import request
|
3 |
-
from flask import render_template
|
4 |
from flask import redirect
|
5 |
-
from flask import
|
|
|
6 |
from flask import send_from_directory
|
7 |
-
import
|
8 |
-
import numpy as np
|
9 |
-
import moduli
|
10 |
-
from hugchat import hugchat
|
11 |
-
from numpy.linalg import norm
|
12 |
-
import datetime
|
13 |
-
#import tensorflow as tf
|
14 |
-
#import tensorflow_hub as hub
|
15 |
-
#import tensorflow_text
|
16 |
from functools import wraps
|
17 |
|
18 |
-
#model_url = "./hub_model/"
|
19 |
-
#hub_layer = hub.load(model_url)
|
20 |
-
|
21 |
app = Flask(__name__)
|
|
|
22 |
|
23 |
def support_jsonp(func):
|
24 |
"""Wraps JSONified output for JSONP requests."""
|
@@ -37,63 +27,26 @@ def support_jsonp(func):
|
|
37 |
return func(*args, **kwargs)
|
38 |
return decorated_function
|
39 |
|
40 |
-
@app.route(
|
41 |
-
def
|
|
|
42 |
return '<br>' \
|
43 |
'<h3><a href="https://www.aubaypoc.altervista.org/la7_demo.php" target="_blank">Vai alla 7Demo!</a></h3>' \
|
44 |
'<br>' \
|
45 |
'<h3><a href="https://www.ftintelligence.altervista.org/qa.php" target="_blank">Vai alla Question Answering Demo!</a></h3>'
|
46 |
-
|
47 |
-
@app.route('/broadcast_labels',methods=['POST','GET'])
|
48 |
-
@support_jsonp
|
49 |
-
def broadcast_labels():
|
50 |
-
#if request.method == 'GET':
|
51 |
-
s=request.args.get('S')
|
52 |
-
dati=moduli.la7_labels(s)
|
53 |
-
output=dati
|
54 |
-
response = jsonify(output)
|
55 |
-
return response
|
56 |
-
|
57 |
-
'''
|
58 |
-
@app.route('/requestsQA',methods=['POST','GET'])
|
59 |
-
@support_jsonp
|
60 |
-
def tasksQA():
|
61 |
-
ris=''
|
62 |
-
if request.method == 'POST':
|
63 |
-
domanda = str(request.form['domanda']).strip()
|
64 |
-
s = str(request.form['S']).strip()
|
65 |
-
ris=moduli.la7_QA(s,domanda,nlp_p)
|
66 |
-
return ris
|
67 |
-
|
68 |
-
@app.route('/requestsSearch',methods=['POST','GET'])
|
69 |
-
@support_jsonp
|
70 |
-
def tasksSearch():
|
71 |
-
response=''
|
72 |
-
if request.method == 'POST':
|
73 |
-
domanda = str(request.form['frase']).strip()
|
74 |
-
s = str(request.form['S']).strip()
|
75 |
-
dati=moduli.la7_Search(s,domanda,hub_layer)
|
76 |
-
output=dati
|
77 |
-
response = jsonify(output)
|
78 |
-
return response
|
79 |
-
|
80 |
@app.route('/predict', methods=['POST','GET'])
|
81 |
@support_jsonp
|
82 |
def predict():
|
83 |
dati=[]
|
84 |
-
|
85 |
-
context=str(request.form['testo']).strip()
|
86 |
-
#question=request.args.get('testo_domanda')
|
87 |
-
question=str(request.form['testo_domanda']).strip()
|
88 |
-
w=moduli.la7_Bot(context,question,hugchat)
|
89 |
d={}
|
90 |
d['risultato']=w
|
91 |
d['nome']='ok'
|
92 |
data=jsonify(d)
|
93 |
data.headers.add('Access-Control-Allow-Origin', '*')
|
94 |
return data
|
95 |
-
|
96 |
|
97 |
if __name__ == "__main__":
|
98 |
-
|
99 |
-
app.run(host='0.0.0.0', port=6060)
|
|
|
1 |
from flask import Flask
|
2 |
from flask import request
|
|
|
3 |
from flask import redirect
|
4 |
+
from flask import render_template
|
5 |
+
from flask import jsonify,current_app
|
6 |
from flask import send_from_directory
|
7 |
+
#from flask_cors import CORS
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
from functools import wraps
|
9 |
|
|
|
|
|
|
|
10 |
app = Flask(__name__)
|
11 |
+
#CORS(app)
|
12 |
|
13 |
def support_jsonp(func):
|
14 |
"""Wraps JSONified output for JSONP requests."""
|
|
|
27 |
return func(*args, **kwargs)
|
28 |
return decorated_function
|
29 |
|
30 |
+
@app.route('/')
|
31 |
+
def hello_world():
|
32 |
+
#return w
|
33 |
return '<br>' \
|
34 |
'<h3><a href="https://www.aubaypoc.altervista.org/la7_demo.php" target="_blank">Vai alla 7Demo!</a></h3>' \
|
35 |
'<br>' \
|
36 |
'<h3><a href="https://www.ftintelligence.altervista.org/qa.php" target="_blank">Vai alla Question Answering Demo!</a></h3>'
|
37 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
@app.route('/predict', methods=['POST','GET'])
|
39 |
@support_jsonp
|
40 |
def predict():
|
41 |
dati=[]
|
42 |
+
w='questa prova'
|
|
|
|
|
|
|
|
|
43 |
d={}
|
44 |
d['risultato']=w
|
45 |
d['nome']='ok'
|
46 |
data=jsonify(d)
|
47 |
data.headers.add('Access-Control-Allow-Origin', '*')
|
48 |
return data
|
49 |
+
|
50 |
|
51 |
if __name__ == "__main__":
|
52 |
+
app.run(host='0.0.0.0', port=7860)
|
|