Spaces:
Sleeping
Sleeping

instead of returning the image bytes to the api user, we are moving towards hosting them on the backend but we need to be careful moving forwards and make sure that we delete the images after use
28d5b3d
from flask import Flask, request, jsonify, render_template | |
from flask_cors import CORS | |
from dataset.iris import iris | |
from opts import options | |
# using the iris data set for every algorithm | |
X, y = iris() | |
app = Flask( | |
__name__, | |
template_folder="templates", | |
) | |
CORS(app, origins="*") | |
def index(): | |
return render_template("index.html") | |
def neural_network(): | |
algorithm = options["neural-network"] | |
args = request.json["arguments"] | |
result = algorithm( | |
X=X, | |
y=y, | |
args=args, | |
) | |
return jsonify(result) | |
def kmeans(): | |
algorithm = options["kmeans-clustering"] | |
args = request.json["arguments"] | |
result = algorithm( | |
X=X, | |
y=y, | |
clusterer="kmeans-clustering", | |
args=args, | |
) | |
return jsonify(result) | |
if __name__ == "__main__": | |
app.run(debug=False) | |