FastAPI served front page not shown on Connect server

Hi,

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 http://127.0.0.1:8000 or http://127.0.0.1:8000/index.html the front page shows. The docs page (http://127.0.0.1:8000/docs) 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 direct.url.link/index.html. (direct.url.link/docs shows the the API document as it should)

When I intentionally spell index.html wrong, like direct.url.link/index.htm, 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 direct.url.link/global.css 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: