FastAPI served front page not shown on Connect server


When I want to share my python script with colleagues to use, I made it a FastAPI app. It serves a front page as a simple interface in addition to API calls.

It runs fine locally. When I open url or the front page shows. The docs page ( also works

However once published to our Connect server, the front page does not show. docs page works though.

When I put the direct link URL in, the page is just blank; the same blank page happens to ( shows the the API document as it should)

When I intentionally spell index.html wrong, like, the page returns 'not found' response:

"detail": "Not Found"

which means the API works properly; but FastAPI served page does not.

Is this an issue with Connect Server config or the app needs to be modification to work properly?

Thanks for any insight!

Additional observation:

Only the index.html doesn't show. Other files in the same location seem to work fine.

For example, a global.css file is in the same path as index.html and properly display the content of the css.

I wonder if Connect server disables html files for FastAPI apps by default?

Did you configure the fastapi to serve static files?

Yes. the app runs fine locally.

I narrowed it down to the paths to javascript in the index.html. Going to try out something and see if it works.

It was the path in the index.html. On local machine, the absolute path in the form of /scripts/abc.js and /img/logo.png are OK. But on the Connect server they have to be relative paths like scripts/abc.js and img/logo.png. This makes sense when thinking about how Connect server serves individual apps.

Also it has to be through the direct link. I haven't found a way to make it work in the "content" page :person_shrugging: