from flask import Flask
from flask import request
from flask import render_template
from flask import redirect
from flask import jsonify
from flask import send_from_directory
import json
import numpy as np
from numpy.linalg import norm
import datetime
import tensorflow as tf
import tensorflow_hub as hub
import tensorflow_text
from functools import wraps
import os
import pickle
import openai
import requests, zipfile, io
model_url = "./hub_model/"
hub_layer = hub.load(model_url)
word=np.load('./static/encodedT.npy',allow_pickle=True)
with open ('./static/textT', 'rb') as fp:
text = pickle.load(fp)
#word_orig=np.array(word, dtype="object")
app = Flask(__name__)
link=os.environ.get('link')
#print('il link รจ:',link)
r = requests.get(link)
z = zipfile.ZipFile(io.BytesIO(r.content))
z.extractall("moduli")
from moduli import pdfricerca
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 flask_app():
return '
' \
'