# Launching different image based on url clicked

**URL:** <https://discourse.jupyter.org/t/launching-different-image-based-on-url-clicked/2729>\
**Category:** JupyterHub\
**Created:** [November 22, 2019, 8:02pm UTC](https://discourse.jupyter.org/t/launching-different-image-based-on-url-clicked/2729 "2019-11-22T20:02:09Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sanjaydatasciencedoj](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/sanjaydatasciencedoj/32/1335_2.png) [@sanjaydatasciencedoj](https://discourse.jupyter.org/u/sanjaydatasciencedoj)\
**Post date:** [November 22, 2019, 8:02pm UTC](https://discourse.jupyter.org/t/launching-different-image-based-on-url-clicked/2729/1 "2019-11-22T20:02:09Z")

</div>

Our use case is that we have two different kinds of exercises: R and Python. We want to have two different images for R and Python. When anyone clicks on R notebook exercise, we want it to open R notebook with R image selected when anyone clicks on python, we want it to open Python notebook with Python image selected?

---

<div class="post-metadata">

**Author:** ![sanjaydatasciencedoj](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/sanjaydatasciencedoj/32/1335_2.png) [@sanjaydatasciencedoj](https://discourse.jupyter.org/u/sanjaydatasciencedoj)\
**Post date:** [November 22, 2019, 8:05pm UTC](https://discourse.jupyter.org/t/launching-different-image-based-on-url-clicked/2729/2 "2019-11-22T20:05:24Z")

</div>

This pull request by @yuvipanda might work in our use case. My only concern is that the user not being able to access the image directly without using nbgitpuller.

---

<div class="post-metadata">

**Author:** ![minrk](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/minrk/32/13_2.png) [@minrk](https://discourse.jupyter.org/u/minrk)\
**Post date:** [December 5, 2019, 2:23pm UTC](https://discourse.jupyter.org/t/launching-different-image-based-on-url-clicked/2729/3 "2019-12-05T14:23:23Z")

</div>

JupyterHub recently started passing the incoming Handler to the Spawner, to allow for exactly this kind of use case. You can check URL params, etc. to change inputs to the Spawner in `Spawner.start`:

```python
class MySpawner(KubeSpawner):
    async def start(self):
        if self.handler:
            profile = self.handler.get_argument('profile', '').lower()
            if profile and profile == 'r':
                self.image = 'myrepo/my-r-image:tag'
            elif profile and profile == 'python':
                self.image = 'myrepo/my-python-image:tag'
            elif profile:
                self.log.warning("Unrecognized profile: %r", profile)
        return super().start()

```
