Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
from datetime import datetime
|
| 3 |
+
|
| 4 |
+
import subprocess
|
| 5 |
+
|
| 6 |
+
# Upgrade Jinja2 package to a specific version
|
| 7 |
+
subprocess.check_call(['pip', 'install', 'jinja2==2.11.3'])
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
from flask import Flask, redirect, render_template, request, url_for
|
| 11 |
+
import streamlit as st
|
| 12 |
+
from model import initialize_index
|
| 13 |
+
|
| 14 |
+
app = Flask(__name__)
|
| 15 |
+
index = None
|
| 16 |
+
|
| 17 |
+
@app.route("/")
|
| 18 |
+
def home():
|
| 19 |
+
return render_template('home.html')
|
| 20 |
+
|
| 21 |
+
@app.route("/get")
|
| 22 |
+
def get_bot_response():
|
| 23 |
+
query_text = request.args.get("msg", None)
|
| 24 |
+
if query_text is None:
|
| 25 |
+
return "Invalid input"
|
| 26 |
+
response = index.query(query_text)
|
| 27 |
+
return str(response), 200
|
| 28 |
+
|
| 29 |
+
if __name__ == "__main__":
|
| 30 |
+
index = initialize_index("index.json")
|
| 31 |
+
app.run(debug=True)
|