julien-c HF staff kramp HF staff commited on
Commit
35cf7cb
1 Parent(s): 975cf74

Add theme parameter to the html exporter (#2)

Browse files

- Add theme parameter to the html exporter (3a2117139a77303d5346d8a221a175fb3310ed87)


Co-authored-by: Bertrand Chevrier <[email protected]>

Files changed (1) hide show
  1. app.py +2 -0
app.py CHANGED
@@ -26,6 +26,7 @@ async def convert(req: Request):
26
  if not url:
27
  raise HTTPException(400, "Param url is missing")
28
  print("\n===", url)
 
29
  r = await client.get(
30
  url,
31
  headers={"Authorization": f"Bearer {os.environ.get('HF_TOKEN')}"},
@@ -57,6 +58,7 @@ async def convert(req: Request):
57
  )
58
 
59
  print(f"Input: nbformat v{notebook_node.nbformat}.{notebook_node.nbformat_minor}")
 
60
  body, _ = html_exporter.from_notebook_node(notebook_node)
61
  # TODO(customize or simplify template?)
62
  # TODO(also check source code for jupyter/nbviewer)
 
26
  if not url:
27
  raise HTTPException(400, "Param url is missing")
28
  print("\n===", url)
29
+ theme = req.query_params.get("theme")
30
  r = await client.get(
31
  url,
32
  headers={"Authorization": f"Bearer {os.environ.get('HF_TOKEN')}"},
 
58
  )
59
 
60
  print(f"Input: nbformat v{notebook_node.nbformat}.{notebook_node.nbformat_minor}")
61
+ html_exporter.theme = "dark" if theme == "dark" else "light"
62
  body, _ = html_exporter.from_notebook_node(notebook_node)
63
  # TODO(customize or simplify template?)
64
  # TODO(also check source code for jupyter/nbviewer)