Expose web apps

Studios can run and expose AI web apps. These public apps also support serverless where the Studio will turn off if the app is not being used and will turn on again if it is being used.

Run and expose AI web apps via public URL.

This is a high-level guide that covers the key points of serving web apps on Studios.

For a more thorough guide check out the deploy AI web apps section.

Use the API builder

To expose a web app via a public URL, open a Studio and install the API builder plugin. Create a new API and add the command that will run your server. Now access the URL from a browser.

Install the API plugin to host a web app and expose a public URL.

Save money with serverless

Serverless is the ability for Studios to sleep when inactive and auto-wake up when active. This saves you money and resources because the Studio only runs when it needs to. For a web app, the Studio will sleep when no users are using the web app. When a user requests the web app, there will be a small delay while the app wakes up, but after that it will be instantaneous.

Save money by enabling Auto start. The studio will stay sleeping until someone visits the public URL.

Multiple apps in one Studio

Studios can host multiple apps at the same time. For example, you can deploy 5 different Streamlit apps and configure serverless for each. Whenever any of the apps are used by a user, the Studio will wake up and render the page. If multiple apps are used, the Studio will route the requests accordingly. In this case, think of a Studio as a load balancer.

Exposing ports

Install the 'Port viewer' plug-in from the menu and open a port that exposes the UI of your application.

View the UI of your application using the 'Port viewer' plug-in.

Examples

The following are various examples for common web frameworks.

Serverless Streamlit

Streamlit is a web framework that mixes the front-end code with the model code. It has a similar event-loop to React but it is built in pure Python. Under the hood, it still generates valid React code, but it does not require the user to know web development. This is useful to build interfaces that require computational code like in AI/ML without needing a stand-alone web app.

This walk-through shows how to run a Streamlit app on a Studio with serverless enabled.

Runing a Streamlit app on a Studio with serverless enabled

Read this in-depth guide on deploying Streamlit apps.

Serverless Gradio

Gradio is a web framework that mixes the front-end code with the model code. It has prebuilt templates for different machine learning tasks (object-detection, classification, etc...). The advantage is that it is fast to develop a visual interface to share how a model performs without needing to know web development. We recommend using this for demos, but using a more traditional web framework for production use cases.

This walk-through shows how to run a Gradio app on a Studio with serverless enabled.

Runing a Gradio app on a Studio with serverless enabled

Read this in-depth guide on deploying Gradio apps.

Serverless React

If you know how to build web apps, need a high-performance front-end for a model targeting a production use case, we recommend you use a traditional web framework like React or Vue.js. In this case, the front-end is separated from the ML back-end which you can treat as a black box API.

On Lightning AI, you can use any web development framework as well. Here's an example of React running serverless.

Use the React plugin to create a high performance web app.

Read this in-depth guide on deploying React apps.

Was this page helpful?

What went wrong?

↑↓ Navigate↵ Open⌘↵ New tabesc Close