yeet
This commit is contained in:
33
app.py
Normal file
33
app.py
Normal file
@@ -0,0 +1,33 @@
|
||||
import os
|
||||
|
||||
from flask import Flask, request, jsonify, render_template
|
||||
|
||||
from main import consult_simba_oracle
|
||||
|
||||
app = Flask(__name__, static_folder="raggr-frontend/dist/static", template_folder="raggr-frontend/dist")
|
||||
|
||||
|
||||
# Serve React static files
|
||||
@app.route('/static/<path:filename>')
|
||||
def static_files(filename):
|
||||
return send_from_directory(app.static_folder, filename)
|
||||
|
||||
# Serve the React app for all routes (catch-all)
|
||||
@app.route('/', defaults={'path': ''})
|
||||
@app.route('/<path:path>')
|
||||
def serve_react_app(path):
|
||||
if path and os.path.exists(os.path.join(app.template_folder, path)):
|
||||
return send_from_directory(app.template_folder, path)
|
||||
return render_template('index.html')
|
||||
|
||||
@app.route("/api/query", methods=["POST"])
|
||||
def query():
|
||||
data = request.get_json()
|
||||
query = data.get("query")
|
||||
return jsonify({"response": consult_simba_oracle(query)})
|
||||
|
||||
@app.route("/api/ingest", methods=["POST"])
|
||||
def webhook():
|
||||
data = request.get_json()
|
||||
print(data)
|
||||
|
||||
Reference in New Issue
Block a user