How do you dynamically start a uvicorn app server process in Streamlit Sharing?

I want to start a uvicorn server on Streamlit Sharing and don’t really know what host address (and port number) to assign in my server class. Running locally I use localhost and 8000 respectively.

Here’s my Server class, the app is a FastAPI app.

import time
import threading
import uvicorn

class Server(uvicorn.Server):

    def __init__(self, app=None, host='127.0.0.1', port=8000, log_level='info'):
        if app is None:
            raise RuntimeError('Error: uvicorn.Server app must be supplied.')
        config = uvicorn.Config(app, host=host, port=port, log_level=log_level)
        super().__init__(config)

    def install_signal_handlers(self):
        pass

    @contextlib.contextmanager
    def run_in_thread(self):
        thread = threading.Thread(target=self.run)
        thread.start()
        try:
            while not self.started:
                time.sleep(1e-3)
            yield
        finally:
            self.should_exit = True
            thread.join()

The GitHub repo is here.

The the app on Streamlit Sharing where I use uvicorn to spawn a FastAPI app, and it is failing, is here.

(Works great locally, as per the GitHub Readme.)

I’ve tried to use host=https://share.streamlit.io/asehmi/fastapi-wrapper-apiness and port=8000 without luck. Maybe uvicorn needs to be configured for HTTPS with certs, etc. (How??), or something else.

Any ideas would be appreciated?

Thanks,
Arvindra