Spaces:
Runtime error
Runtime error
Download flask_api.py from Reality123b/RelayServer: direct link, hf CLI and curl.
- Browser
- Download file 873 Bytes
-
https://huggingface.co/spaces/Reality123b/RelayServer/resolve/main/flask_api.py
- Command line
-
hf download hf://spaces/Reality123b/RelayServer/flask_api.py
-
curl -L -o flask_api.py https://huggingface.co/spaces/Reality123b/RelayServer/resolve/main/flask_api.py
873 Bytes
| from flask import Flask, jsonify, send_from_directory, abort | |
| import os | |
| app = Flask(__name__) | |
| DATASETS_DIR = os.path.abspath(os.getenv("DATASETS_DIR", "./datasets")) | |
| def health(): | |
| return jsonify({"status": "OK", "service": "flask", "timestamp": __import__('datetime').datetime.utcnow().isoformat()}) | |
| def list_datasets(): | |
| if not os.path.isdir(DATASETS_DIR): | |
| return jsonify({"error": "Datasets directory not found"}), 404 | |
| files = os.listdir(DATASETS_DIR) | |
| return jsonify({"datasets": files}) | |
| def get_dataset(filename): | |
| try: | |
| return send_from_directory(DATASETS_DIR, filename, as_attachment=True) | |
| except FileNotFoundError: | |
| abort(404) | |
| if __name__ == '__main__': | |
| app.run(host="0.0.0.0", port=5000) |