What are customizable subdomains and what possibilities do they offer?
We have already deployed two applications on Streamlit Cloud: the NLP App and the COVID-19 Detection Tool. So, we are quite familiar with the process, and even how to solve problems arising due to big files or a need for unconventional libraries.
Upon deploying our application on Community Cloud, it is assigned an automatically generated subdomain, which is structured based on our GitHub repository. This subdomain, unique to our application, serves as a means to share the app with others. Nevertheless, the default subdomain can often be cumbersome and not particularly user-friendly. For instance, a subdomain such as the following may not be easily memorable:
https://streamlit-demo-self-driving-streamlit-app-8jya0g.streamlit.app
To enhance shareability and recognition, we have the option to establish a custom subdomain. This customization allows the subdomain to better represent the content of our app, our personal brand, or any other preferred aspect. The custom URL would then be formatted as follows:
<your-custom-subdomain>.streamlit.app
To tailor the subdomain of your application within Streamlit’s Cloud workspace, follow these straightforward steps:
- Navigate to the right of your app, click on the ︙ overflow menu, and then select Settings:
Figure 15.13: Deployed app settings on Streamlit Cloud
- In the app settings modal, access the General tab. Here, you’ll find your app’s current unique subdomain.
- Choose a custom subdomain that is between 6 and 63 characters long for your app’s URL.
- Click Save to confirm:
Figure 15.14: A new subdomain for our app
This process is quick and efficient. Once completed, your app will be accessible via the newly set custom subdomain URL. In cases where the chosen custom subdomain is unavailable (for instance, if it is already in use), an error message will be displayed, prompting you to select a different subdomain, as shown in the following screenshot:
Figure 15.15: “This subdomain is already taken” error message
Being able to select a subdomain name that perfectly suits the aim of our web application is a very powerful customization.
Summary
In this chapter, we covered some topics that can really increase the level of our web applications.
First of all, we saw what forms are and how to use them, discovering that having independent groups of widgets inside our web apps can make a big difference. All we need to do is define these forms and include some widgets inside them, using a button to trigger the widgets. Even the button is customizable since it can be included in the form or placed outside it.
Further, we learned that Session State is an incredibly powerful weapon in our hands. At last, we can persist the values of our variables, and this opens up an incredible scenario of use cases to us. Moreover, thanks to callbacks, we can decide what to do when a user interacts with our widgets, calling back fully customized functions that completely match our needs.
Finally, by customizing the subdomains of our deployed web applications, we achieved two targets: we made them much easier to remember and we gave them a very professional touch!
In the next and final chapter, we are going to sum up the long journey we’ve made together, highlighting considerations about the Streamlit framework, discussing what the very important takeaways are, and giving some suggestions for the next steps.