From 51164f57a2434fc27999401f67fdf29df25c4b0b Mon Sep 17 00:00:00 2001 From: Jeffrey Morgan Date: Sun, 25 Jun 2023 14:22:07 -0400 Subject: [PATCH] add `GET /models` endpoint --- proto.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/proto.py b/proto.py index d8812e7a..1c12db52 100644 --- a/proto.py +++ b/proto.py @@ -74,6 +74,12 @@ def generate(): stream_with_context(stream_response()), mimetype="text/event-stream" ) +@app.route("/models", methods=["GET"]) +def models(): + all_files = os.listdir("./models") + bin_files = [file.replace(".bin", "") for file in all_files if file.endswith(".bin")] + return Response(json.dumps(bin_files), mimetype="application/json") + if __name__ == "__main__": app.run(debug=True, threaded=True, port=5001) app.run()