from flask import Flask from flask import request from flask import redirect from flask import render_template from flask import jsonify,current_app from flask import send_from_directory #from flask_cors import CORS from functools import wraps app = Flask(__name__) #CORS(app) def support_jsonp(func): """Wraps JSONified output for JSONP requests.""" @wraps(func) def decorated_function(*args, **kwargs): callback = request.args.get('callback', False) if callback: resp = func(*args, **kwargs) resp.set_data('{}({})'.format( str(callback), resp.get_data(as_text=True) )) resp.mimetype = 'application/javascript' return resp else: return func(*args, **kwargs) return decorated_function @app.route('/') def hello_world(): #return w return '
' \ '

Vai alla 7Demo!

' \ '
' \ '

Vai alla Question Answering Demo!

' @app.route('/predict', methods=['POST','GET']) @support_jsonp def predict(): dati=[] w='questa prova' d={} d['risultato']=w d['nome']='ok' data=jsonify(d) data.headers.add('Access-Control-Allow-Origin', '*') return data if __name__ == "__main__": app.run(host='0.0.0.0', port=7860)