File size: 1,050 Bytes
669b6be d8f06d4 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
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)
|