# Slicer windows in a custom web application

**URL:** <https://discourse.slicer.org/t/slicer-windows-in-a-custom-web-application/24706>\
**Category:** Support\
**Tags:** jupyter, web\
**Created:** [August 10, 2022, 8:35am UTC](https://discourse.slicer.org/t/slicer-windows-in-a-custom-web-application/24706 "2022-08-10T08:35:12Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![NaglisR](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/naglisr/32/16280_2.png) [@NaglisR](https://discourse.slicer.org/u/NaglisR)\
**Post date:** [August 10, 2022, 8:35am UTC](https://discourse.slicer.org/t/slicer-windows-in-a-custom-web-application/24706/1 "2022-08-10T08:35:12Z")

</div>

Hi all, I have a somewhat abstract question regarding integrating slicer windows in a custom web application window. Generally I suppose it should work something like this [https://youtu.be/vTGQMDIqL9k](https://youtu.be/vTGQMDIqL9k) meaning that the Slicer instance would be running in a docker instance (deployed in bundle with other docker containers) which would be able to receive requests and open a selected study in a slicer window on command. However, optimally I would be looking for a way to do an even deeper integration, which would allow to display a custom slicer window as an iframe or similar in an interactive custom html page.  
Optimally it should look like something like SlicerJupyter UI, only integrated in a custom UI and without the code.  
 ![Screenshot from 2022-08-10 11-29-02](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/a/c/ac467091257e3c32a4b76b4219b6b59433a9f40f.png)  
Is there a way to do this with Slicer, if so what could be the best way to do it (using SlicerDocker/JupyterSlicer/SlicerWeb?).

I am not sure if there are existing examples of a similar type of integration. Thanks to anyone in advance :).

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [August 10, 2022, 2:07pm UTC](https://discourse.slicer.org/t/slicer-windows-in-a-custom-web-application/24706/2 "2022-08-10T14:07:23Z")

</div>

It sounds like you have a use case that would be a good fit for the WebServer module now in Slicer 5.0.3 (the module used to be in the SlicerWeb extension prototype). The WebServer exposes a rest api that can be used to control Slicer and get rendered images.

[https://slicer.readthedocs.io/en/latest/user\_guide/modules/webserver.html?highlight=webserver](https://slicer.readthedocs.io/en/latest/user_guide/modules/webserver.html?highlight=webserver)

---

<div class="post-metadata">

**Author:** ![NaglisR](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/naglisr/32/16280_2.png) [@NaglisR](https://discourse.slicer.org/u/NaglisR)\
**Post date:** [August 10, 2022, 3:00pm UTC](https://discourse.slicer.org/t/slicer-windows-in-a-custom-web-application/24706/3 "2022-08-10T15:00:04Z")

</div>

This looks very promising, thank you! Is it possible to set it up to support multiple concurrent users?  
Will investigate and try it out.

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [August 10, 2022, 6:00pm UTC](https://discourse.slicer.org/t/slicer-windows-in-a-custom-web-application/24706/4 "2022-08-10T18:00:33Z")

</div>

> [@NaglisR](#):
>
> Is it possible to set it up to support multiple concurrent users?

Yes, if the concurrent users need to access the same data and other state they can access the same Slicer instance. If they need a private session then the server can be run from different instances of Slicer using distinct ports (e.g. in different docker containers or just running in different processes). Let us know how it goes!

---

<div class="post-metadata">

**Author:** ![NaglisR](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/naglisr/32/16280_2.png) [@NaglisR](https://discourse.slicer.org/u/NaglisR)\
**Post date:** [August 11, 2022, 7:49am UTC](https://discourse.slicer.org/t/slicer-windows-in-a-custom-web-application/24706/5 "2022-08-11T07:49:17Z")

</div>

Understood, thank you.  
I am stuggling a bit to find these endpoints described in the Remote Rendering:  
“There are several endpoints to get png images from slice views and 3D views. These endpoints allow control of slice offset or 3D camera view (see method doc strings in the source code for options since there is currently no auto-generated api documentation)”  
Also, are these enpoints designed to return static png images, or is there a posibility to return a dynamic endpoint, which return a red slice window for example, with the scolling controls, similarly like a JupyterSlicer function?

```auto
from ipywidgets import interact
@interact(position=(0,100))
def update(position=50):
    return slicernb.ViewSliceDisplay('Red', positionPercent=position)

```

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [August 11, 2022, 2:20pm UTC](https://discourse.slicer.org/t/slicer-windows-in-a-custom-web-application/24706/6 "2022-08-11T14:20:15Z")

</div>

The assumption is that the client (javascript) would implement all the control like sliders to touch interactions and just use the WebServer api to set rendering parameters and retrieve rendered data. So you would build the `scrollTo` parameter value based on the state of the slider and get back the png of the current slice.

> <https://github.com/Slicer/Slicer/blob/main/Modules/Scripted/WebServer/Resources/docroot/index.html#L51-L55>
