Download kb_server.py from ameobius/dev-box: direct link, hf CLI and curl.
- Browser
- Download file 1.01 kB
-
https://huggingface.co/spaces/ameobius/dev-box/resolve/main/kb_server.py
- Command line
-
hf download hf://spaces/ameobius/dev-box/kb_server.py
-
curl -L -o kb_server.py https://huggingface.co/spaces/ameobius/dev-box/resolve/main/kb_server.py
1.01 kB
| #!/usr/bin/env python3 | |
| """Simple KB HTTP server for Krevetka on HF Space. | |
| Serves /app/kb/ directory on port 8811. | |
| Replaces the 192.168.0.5:8811 local server. | |
| """ | |
| import os | |
| from flask import Flask, send_from_directory, jsonify | |
| KB_DIR = "/app/kb" | |
| app = Flask(__name__) | |
| def list_dir(): | |
| """Directory listing (matches original server format).""" | |
| items = [] | |
| for entry in sorted(os.listdir(KB_DIR)): | |
| full = os.path.join(KB_DIR, entry) | |
| if os.path.isdir(full): | |
| items.append(f'{entry}/') | |
| else: | |
| items.append(entry) | |
| return '<!DOCTYPE HTML><html><body><ul>' + \ | |
| ''.join(f'<li><a href="{i}">{i}</a></li>' for i in items) + \ | |
| '</ul></body></html>' | |
| def serve_file(filepath): | |
| """Serve any KB file.""" | |
| return send_from_directory(KB_DIR, filepath) | |
| def health(): | |
| return jsonify({"status": "ok"}) | |
| if __name__ == "__main__": | |
| app.run(host="0.0.0.0", port=8811) | |