aboutsummaryrefslogtreecommitdiffstats
path: root/cargo/cargo.py
diff options
context:
space:
mode:
Diffstat (limited to 'cargo/cargo.py')
-rwxr-xr-xcargo/cargo.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/cargo/cargo.py b/cargo/cargo.py
new file mode 100755
index 0000000..a819a30
--- /dev/null
+++ b/cargo/cargo.py
@@ -0,0 +1,26 @@
+#!/usr/bin/env python3
+import http.server
+import huggingface_hub as hh
+import socketserver
+import os
+
+
+# https://huggingface.co/docs/huggingface_hub/how-to-downstream
+def download(path: str = ".") -> None:
+ bart_pretrained = hh.hf_hub_url(
+ "lysandre/arxiv-nlp", filename="config.json"
+ )
+ hh.cached_download(bart_pretrained)
+
+
+def serve() -> None:
+ handler = http.server.SimpleHTTPRequestHandler
+ PORT = os.environ["SERVER_PORT"]
+
+ download(os.environ["SERVER_VAULT"])
+ with socketserver.TCPServer(("", int(PORT)), handler) as httpd:
+ httpd.serve_forever()
+
+
+if __name__ == "__main__":
+ serve()