julien-c HF staff commited on
Commit
b5bf16b
1 Parent(s): 5521786

scaffolding

Browse files
Files changed (7) hide show
  1. .gitignore +1 -0
  2. .vscode/settings.json +4 -0
  3. README.md +3 -3
  4. app.py +31 -0
  5. requirements.txt +3 -0
  6. static/.prettierrc +3 -0
  7. static/index.html +85 -0
.gitignore ADDED
@@ -0,0 +1 @@
 
 
1
+ .env/
.vscode/settings.json ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ {
2
+ "editor.formatOnSave": true,
3
+ "python.formatting.provider": "black"
4
+ }
README.md CHANGED
@@ -1,8 +1,8 @@
1
  ---
2
- title: Nbconvert
3
- emoji: 📈
4
  colorFrom: purple
5
- colorTo: blue
6
  sdk: docker
7
  pinned: false
8
  license: mit
 
1
  ---
2
+ title: nbconvert
3
+ emoji: 💪
4
  colorFrom: purple
5
+ colorTo: purple
6
  sdk: docker
7
  pinned: false
8
  license: mit
app.py ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from starlette.applications import Starlette
2
+ from starlette.exceptions import HTTPException
3
+ from starlette.responses import FileResponse, JSONResponse, HTMLResponse
4
+ from starlette.requests import Request
5
+ from starlette.routing import Route
6
+
7
+
8
+ async def homepage(_):
9
+ return FileResponse("static/index.html")
10
+
11
+
12
+ async def healthz(_):
13
+ return JSONResponse({"success": True})
14
+
15
+
16
+ async def convert(req: Request):
17
+ url = req.query_params.get("url")
18
+ if not url:
19
+ raise HTTPException(400, "Param url is missing")
20
+ print(url)
21
+ return HTMLResponse("<strong>FOO</strong>")
22
+
23
+
24
+ app = Starlette(
25
+ debug=True,
26
+ routes=[
27
+ Route("/", homepage),
28
+ Route("/healthz", healthz),
29
+ Route("/convert", convert),
30
+ ],
31
+ )
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ starlette==0.23.1
2
+ nbconvert==7.2.8
3
+ uvicorn==0.20.0
static/.prettierrc ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ {
2
+ "useTabs": true
3
+ }
static/index.html ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
+ <script src="https://cdn.tailwindcss.com"></script>
7
+ </head>
8
+ <body>
9
+ <div class="container mx-auto py-4">
10
+ <h1 class="text-3xl font-bold text-center">nbconvert-server</h1>
11
+ <p class="text-center">
12
+ An internal API used as a backend for notebook rendering on the Hub
13
+ </p>
14
+ <svg class="mx-auto mb-8" width="32" height="32" viewBox="0 0 24 24">
15
+ <path
16
+ fill="#888888"
17
+ fill-rule="evenodd"
18
+ d="M16.48 14h4.02a2.5 2.5 0 1 0 0-5H6.618a1 1 0 0 1-.894-.553l-.448-.894A1 1 0 0 0 4.382 7H2.517a1 1 0 0 0-.92 1.394l2.143 5a1 1 0 0 0 .92.606h3.863a1 1 0 0 1 .928 1.371L8.55 17.63A1 1 0 0 0 9.477 19h2.042a1 1 0 0 0 .781-.375l3.4-4.25a1 1 0 0 1 .78-.375zM9.5 8h4.75L12.3 5.4a1 1 0 0 0-.8-.4H9.618a1 1 0 0 0-.894 1.447L9.5 8z"
19
+ clip-rule="evenodd"
20
+ />
21
+ </svg>
22
+
23
+ <div class="w-96 mx-auto">
24
+ <p>Sample notebooks:</p>
25
+ <ul class="list-disc">
26
+ <li>
27
+ climategan (LFS-stored > 10MB)
28
+ <a
29
+ target="_blank"
30
+ class="underline"
31
+ href="/convert?url=https://huggingface.co/spaces/NimaBoscarino/climategan/blob/main/notebooks/plot_metrics.ipynb"
32
+ >
33
+ html</a
34
+ >,
35
+ <a
36
+ target="_blank"
37
+ class="underline"
38
+ href="https://huggingface.co/spaces/NimaBoscarino/climategan/blob/main/notebooks/plot_metrics.ipynb"
39
+ >
40
+ on Hub
41
+ </a>
42
+ </li>
43
+ <li>
44
+ Fake_News_Classificaton.ipynb (stored in raw git)
45
+ <a
46
+ target="_blank"
47
+ class="underline"
48
+ href="/convert?url=https://huggingface.co/pceiyos/fake_news_detection_nlp/blob/main/Fake_News_Classificaton.ipynb"
49
+ >
50
+ html</a
51
+ >,
52
+ <a
53
+ target="_blank"
54
+ class="underline"
55
+ href="https://huggingface.co/pceiyos/fake_news_detection_nlp/blob/main/Fake_News_Classificaton.ipynb"
56
+ >
57
+ on Hub
58
+ </a>
59
+ </li>
60
+ <li>
61
+ Dall-e mini (specific revision)
62
+ <a
63
+ target="_blank"
64
+ class="underline"
65
+ href="/convert?url=https://huggingface.co/spaces/dalle-mini/dalle-mini/blob/63679e968109278c5f0169100b1755bbda9f4bc6/tools/inference/inference_pipeline.ipynb"
66
+ >
67
+ html</a
68
+ >,
69
+ <a
70
+ target="_blank"
71
+ class="underline"
72
+ href="https://huggingface.co/spaces/dalle-mini/dalle-mini/blob/63679e968109278c5f0169100b1755bbda9f4bc6/tools/inference/inference_pipeline.ipynb"
73
+ >
74
+ on Hub
75
+ </a>
76
+ </li>
77
+ </ul>
78
+ </div>
79
+
80
+ <div class="text-xs text-gray-500 text-center mt-10 mb-4">
81
+ ping @julien-c if anything looks wrong
82
+ </div>
83
+ </div>
84
+ </body>
85
+ </html>