Host a Custom App
Latch Pods make it easy to host any custom application, such as Dash Apps, RShiny, Streamlit, and more, on Latch.
Setting up your Custom App
In this guide, we will walk through step-by-step how you can set up your own custom application.
Prepare your app.
Ensure your app is installed and configured according to its documentation.
Modify the startup script.
Make sure the app is on port 5000, and listens to 0.0.0.0
not localhost
.
- Here are a few examples of modifying the script in different languages.
-
ShinyApp
Replace “path/to/your/app” with the actual path to your Shiny app directory.
-
Dash App
In your main Python script:
-
Streamlit
To run a Streamlit app, use the following command in your terminal, specifying the app file:
Replace path/to/your/app.py with the actual path to your Streamlit app file.
-
After you've set the app to the correct port and host, start your Custom App.
In the terminal, start the custom app service:
The command will run the script under /opt/latch/custom_app
and start the application for the first time on Pod.
Enable the custom app service.
To make the app automatically start as the user starts the Pod the next time, enable the Latch custom app service:
Toggle on 'Show Custom App (Port 5000)'.
To verify if the Pod is running, navigate to the Pods page, and select Manage Pod go to Pod’s settings.
This will display a third button on the Pods card, which we can click to open the custom app running on port 5000.
If the app is set up correctly, you should see it open up in a new tab!
If you receive a 502 Gateway Error, that means the app has failed to start. Visit our Debugging an Application section for further instructions.
Open your App.
To see the app in action, stop and start your Pod, and click on the ‘Open Custom App’ button.
Advanced: Enabling the Application to Read from Latch Data
Latch Pods come with Latch Data FUSE (Filesystem in Userspace), which displays the entire filesystem on Latch Data on pods.
LData FUSE is a file system that allows you to access Latch Data within Pods. LData is mounted automatically when starting a pod, and its content can be inspected under the directory /ldata.
To access LData FUSE:
- Start a new Latch Pod.
- Navigate to the /ldata directory in your Pod.
- You will see the entire Latch Data filesystem mirrored in this directory.
Debugging An Application
If you see a 502 Gateway Error after clicking ‘Open Custom App’, it means the app has not been started correctly, and there is no application running on port 5000.
To see the logs of why the application may have failed, in your terminal, type:
The same command can also be used to inspect any other errors that occur while the app is running.
Was this page helpful?