Spaces:
Runtime error
Runtime error
import os | |
import subprocess | |
from flask import Flask, render_template, Response, request, jsonify | |
from hello import hello | |
app = Flask(__name__) | |
def index(): | |
return render_template("index.html", logs_url="/logs", api_url="/api/generate") | |
def logs(): | |
def stream_logs(): | |
process = subprocess.Popen(["docker-compose", "logs", "-f", "ollama"], stdout=subprocess.PIPE) | |
for line in iter(process.stdout.readline, b''): | |
yield line.decode('utf-8') | |
return Response(stream_logs(), mimetype='text/plain') | |
def generate(): | |
data = request.get_json() | |
prompt = data.get("prompt") | |
if not prompt: | |
return jsonify({"error": "Missing prompt"}), 400 | |
# TODO: Implement logic to send prompt to Ollama and get response | |
response = "This is a placeholder response" | |
return jsonify({"response": response}) | |
if __name__ == "__main__": | |
app.run(host="0.0.0.0", port=5000, debug=True) | |