blob: a819a30990c064da555df877785edd4e6680728d (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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()
|