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" | |
def index(): | |
"""Render the main page.""" | |
return render_template('index.html') | |
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()) | |
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()) | |
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) | |