Add theme parameter to the html exporter

#2
by kramp HF staff - opened
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)