# How to add my own custom handlers in jupyter\_server of jupyterhub platform

**URL:** <https://discourse.jupyter.org/t/how-to-add-my-own-custom-handlers-in-jupyter-server-of-jupyterhub-platform/12356>\
**Category:** JupyterHub\
**Tags:** help-wanted\
**Created:** [December 28, 2021, 2:40am UTC](https://discourse.jupyter.org/t/how-to-add-my-own-custom-handlers-in-jupyter-server-of-jupyterhub-platform/12356 "2021-12-28T02:40:35Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![pklcoder](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/pklcoder/32/6079_2.png) [@pklcoder](https://discourse.jupyter.org/u/pklcoder)\
**Post date:** [December 28, 2021, 2:40am UTC](https://discourse.jupyter.org/t/how-to-add-my-own-custom-handlers-in-jupyter-server-of-jupyterhub-platform/12356/1 "2021-12-28T02:40:35Z")

</div>

i use the jupyterhub to support 20users deal data in python kernels.  
The jupyterhub is installed as the [GitHub - jupyterhub/jupyterhub: Multi-user server for Jupyter notebooks](https://github.com/jupyterhub/jupyterhub) described .  
jupyterhub include jupyterlab /jupter\_server/notebook/juupyter\_core and so on ,i want add some functions to jupyterhub.  
i want to add my own custom handlers on jupyterhub platform to deal some request from browser .  
i add a new handler on the jupyter\_server( v1.11.1)[[GitHub - jupyter-server/jupyter\_server: The backend—i.e. core services, APIs, and REST endpoints—to Jupyter web applications.](https://github.com/jupyter-server/jupyter_server)] in the jupyter\_server\jupyter\_server\services\api\handlers.py .  
the add content ：  
class UserCustomHandler(APIHandler):  
“”"  
User Customization function  
“”"  
\_track\_activity = False

```
@web.authenticated
def get(self):
    # 
    with open("/tmp/test.txt", 'a', encoding="utf-8") as f:
        f.write("====begain run in UserCustomHandler=====")

```

the default handler:  
default\_handlers = [  
(r"/api/spec.yaml", APISpecHandler),  
(r"/api/status", APIStatusHandler),  
(r"/api/customhandler", UserCustomHandler),  
]  
then i build and install the jupyter\_server in my jupyterhub.  
i send the request to http:ip:9000/user/lihua//api/customhandler but it does not work .

who can tell me how to add a new handler in jupyter\_server of jupyterhub platform or add a new handler directly on jupyterhub source code or add a new handler on jupyterlab ?  
the version information

notebook==6.4.0  
jupyter-client==6.2.0  
jupyter-contrib-core==0.3.3  
jupyter-contrib-nbextensions==0.5.1  
jupyter-core==4.7.1  
jupyter-hdfscm==0.2.0+0.g427e8c8.dirty  
jupyter-highlight-selected-word==0.2.0  
jupyter-latex-envs==1.4.6  
jupyter-nbextensions-configurator==0.4.1  
jupyter-resource-usage==0.6.0  
jupyter-server==1.11.1  
jupyterhub==1.0.0  
jupyterhub-yarnspawner==0.4.0+2.g1c40f52.dirty  
jupyterlab==3.2.1  
jupyterlab-pygments==0.1.2  
jupyterlab-server==2.8.2  
jupyterlab-system-monitor==0.8.0  
jupyterlab-topbar==0.6.1

thanks.

---

<div class="post-metadata">

**Author:** ![manics](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/manics/32/85_2.png) [@manics](https://discourse.jupyter.org/u/manics)\
**Post date:** [December 28, 2021, 4:42pm UTC](https://discourse.jupyter.org/t/how-to-add-my-own-custom-handlers-in-jupyter-server-of-jupyterhub-platform/12356/2 "2021-12-28T16:42:47Z")

</div>

JupyterHub and JupyterLab/jupyter-server are separate applications. JupyterHub launches JupyterLab (or whatever singleuser-server you’ve configured), but once it’s started it proxies all traffic through to JupyterLab.

It sounds like your problem is with jupyter-server/lab/notebook rather than JupyterHub? If so you should be able to develop/debug/test your extension without JupyterHub.

It might help others if you can format your post with Markdown code blocks, see for example [Creating and highlighting code blocks - GitHub Docs](https://docs.github.com/en/github/writing-on-github/working-with-advanced-formatting/creating-and-highlighting-code-blocks)

---

<div class="post-metadata">

**Author:** ![pklcoder](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/pklcoder/32/6079_2.png) [@pklcoder](https://discourse.jupyter.org/u/pklcoder)\
**Post date:** [January 4, 2022, 10:04am UTC](https://discourse.jupyter.org/t/how-to-add-my-own-custom-handlers-in-jupyter-server-of-jupyterhub-platform/12356/3 "2022-01-04T10:04:21Z")

</div>

I finally solve this issue . One should add their new handler in the notebook source code[[GitHub - jupyter/notebook: Jupyter Interactive Notebook](https://github.com/jupyter/notebook.git)] at this version of jupyterhub .
