UB_VSA / buffalo_rag /frontend /flask_app.py
Apurva Umredkar
added backend functionality
d8f06d4
from flask import Flask, render_template, request, jsonify
import requests
import os
import json
from datetime import datetime
app = Flask(__name__)
# API configuration
API_URL = "http://localhost:8000/api"
@app.route('/')
def index():
"""Render the main page."""
return render_template('index.html')
@app.route('/api/ask', methods=['POST'])
def ask():
"""Proxy API call to the FastAPI backend."""
data = request.json
response = requests.post(f"{API_URL}/ask", json=data)
return jsonify(response.json())
@app.route('/api/scrape', methods=['POST'])
def scrape():
"""Proxy API call to trigger web scraping."""
data = request.json
response = requests.post(f"{API_URL}/scrape", json=data)
return jsonify(response.json())
@app.route('/api/refresh-index', methods=['POST'])
def refresh_index():
"""Proxy API call to refresh the vector index."""
response = requests.post(f"{API_URL}/refresh-index")
return jsonify(response.json())
if __name__ == '__main__':
app.run(host="0.0.0.0", port=7860)