from flask import render_template, jsonify, Flask, redirect, url_for, request
from app import app
import random
import os
# import tensorflow as tf
# import numpy as np
# import sys
# import spacy

# nlp = spacy.load('en')

# sys.path.insert(0, "/content/bert_experimental")

# from bert_experimental.finetuning.text_preprocessing import build_preprocessor
# from bert_experimental.finetuning.graph_ops import load_graph
# restored_graph = load_graph("models/frozen_graph.pb")
# graph_ops = restored_graph.get_operations()
# input_op, output_op = graph_ops[0].name, graph_ops[-1].name
# x = restored_graph.get_tensor_by_name(input_op + ':0')
# y = restored_graph.get_tensor_by_name(output_op + ':0')
# preprocessor = build_preprocessor("./uncased_L-12_H-768_A-12/vocab.txt", 256)
# py_func = tf.numpy_function(preprocessor, [x], [tf.int32, tf.int32, tf.int32], name='preprocessor')
# py_func = tf.numpy_function(preprocessor, [x], [tf.int32, tf.int32, tf.int32])
# sess = tf.Session(graph=restored_graph)
# delimiter = " ||| "

@app.route('/')
def index1():
    return render_template('index.html', title='Home')

	
@app.route('/predict', methods = ['GET', 'POST'])
def upload_file():
   if request.method == 'POST':
      exp_st = request.form.get('exp')
      job_st = request.form.get('job')
      # y_out = sess.run(y, feed_dict={
      #   x: pd.DataFrame([delimiter.join((exp_st, job_st ))], columns=['name'])
      # })
      # doc1 = nlp(exp_st)
      # doc2 = nlp(job_st )
      # y_out2 = doc1.similarity(doc2)
   return render_template('index.html', title='Success', predictions=80, predictions_sp =75, exp=exp_st, job= job_st)


@app.route('/index')
def index():
    return render_template('index.html', title='Home')

@app.route('/map')
def map():
    return render_template('map.html', title='Map')


@app.route('/map/refresh', methods=['POST'])
def map_refresh():
    points = [(random.uniform(48.8434100, 48.8634100),
               random.uniform(2.3388000, 2.3588000))
              for _ in range(random.randint(2, 9))]
    return jsonify({'points': points})


@app.route('/contact')
def contact():
    return render_template('contact.html', title='Contact')
[((1029, 1043), 'app.app.route', 'app.route', (['"""/"""'], {}), "('/')\n", (1038, 1043), False, 'from app import app\n'), ((1117, 1163), 'app.app.route', 'app.route', (['"""/predict"""'], {'methods': "['GET', 'POST']"}), "('/predict', methods=['GET', 'POST'])\n", (1126, 1163), False, 'from app import app\n'), ((1642, 1661), 'app.app.route', 'app.route', (['"""/index"""'], {}), "('/index')\n", (1651, 1661), False, 'from app import app\n'), ((1732, 1749), 'app.app.route', 'app.route', (['"""/map"""'], {}), "('/map')\n", (1741, 1749), False, 'from app import app\n'), ((1816, 1859), 'app.app.route', 'app.route', (['"""/map/refresh"""'], {'methods': "['POST']"}), "('/map/refresh', methods=['POST'])\n", (1825, 1859), False, 'from app import app\n'), ((2081, 2102), 'app.app.route', 'app.route', (['"""/contact"""'], {}), "('/contact')\n", (2090, 2102), False, 'from app import app\n'), ((1069, 1112), 'flask.render_template', 'render_template', (['"""index.html"""'], {'title': '"""Home"""'}), "('index.html', title='Home')\n", (1084, 1112), False, 'from flask import render_template, jsonify, Flask, redirect, url_for, request\n'), ((1531, 1640), 'flask.render_template', 'render_template', (['"""index.html"""'], {'title': '"""Success"""', 'predictions': '(80)', 'predictions_sp': '(75)', 'exp': 'exp_st', 'job': 'job_st'}), "('index.html', title='Success', predictions=80,\n    predictions_sp=75, exp=exp_st, job=job_st)\n", (1546, 1640), False, 'from flask import render_template, jsonify, Flask, redirect, url_for, request\n'), ((1686, 1729), 'flask.render_template', 'render_template', (['"""index.html"""'], {'title': '"""Home"""'}), "('index.html', title='Home')\n", (1701, 1729), False, 'from flask import render_template, jsonify, Flask, redirect, url_for, request\n'), ((1772, 1812), 'flask.render_template', 'render_template', (['"""map.html"""'], {'title': '"""Map"""'}), "('map.html', title='Map')\n", (1787, 1812), False, 'from flask import render_template, jsonify, Flask, redirect, url_for, request\n'), ((2050, 2077), 'flask.jsonify', 'jsonify', (["{'points': points}"], {}), "({'points': points})\n", (2057, 2077), False, 'from flask import render_template, jsonify, Flask, redirect, url_for, request\n'), ((2129, 2177), 'flask.render_template', 'render_template', (['"""contact.html"""'], {'title': '"""Contact"""'}), "('contact.html', title='Contact')\n", (2144, 2177), False, 'from flask import render_template, jsonify, Flask, redirect, url_for, request\n'), ((1232, 1255), 'flask.request.form.get', 'request.form.get', (['"""exp"""'], {}), "('exp')\n", (1248, 1255), False, 'from flask import render_template, jsonify, Flask, redirect, url_for, request\n'), ((1271, 1294), 'flask.request.form.get', 'request.form.get', (['"""job"""'], {}), "('job')\n", (1287, 1294), False, 'from flask import render_template, jsonify, Flask, redirect, url_for, request\n'), ((1894, 1928), 'random.uniform', 'random.uniform', (['(48.84341)', '(48.86341)'], {}), '(48.84341, 48.86341)\n', (1908, 1928), False, 'import random\n'), ((1949, 1979), 'random.uniform', 'random.uniform', (['(2.3388)', '(2.3588)'], {}), '(2.3388, 2.3588)\n', (1963, 1979), False, 'import random\n'), ((2016, 2036), 'random.randint', 'random.randint', (['(2)', '(9)'], {}), '(2, 9)\n', (2030, 2036), False, 'import random\n')]