mirror of
https://github.com/jupyterhub/jupyterhub.git
synced 2025-10-17 06:52:59 +00:00
fastapi service example
This commit is contained in:
16
examples/service-fastapi/jupyterhub_config.py
Normal file
16
examples/service-fastapi/jupyterhub_config.py
Normal file
@@ -0,0 +1,16 @@
|
||||
import os
|
||||
|
||||
service = {
|
||||
"name": "fastapi",
|
||||
"url": "http://127.0.0.1:10202",
|
||||
"command": ["uvicorn", "app:app", "--port", "10202"],
|
||||
}
|
||||
# If running behind a proxy, or in Docker / Kubernetes infrastructure,
|
||||
# you probably need to set a different public Hub host than the
|
||||
# internal JUPYTERHUB_API_URL host
|
||||
if "PUBLIC_HOST" in os.environ:
|
||||
public_host = os.environ["PUBLIC_HOST"]
|
||||
service["oauth_redirect_uri"] = f"{public_host}/services/fastapi/oauth_callback"
|
||||
service["environment"] = {"PUBLIC_HOST": public_host}
|
||||
|
||||
c.JupyterHub.services = [service]
|
Reference in New Issue
Block a user