Skip to content

How to build hash routing in remix? #10386

Closed Answered by InfernalAzazel
InfernalAzazel asked this question in Q&A
Discussion options

You must be logged in to vote

Fastapi mount remix spa final solution

static.py

from fastapi.responses import FileResponse

from app.settings import settings

router = APIRouter()


@router.get('/{path:path}', include_in_schema=False)
async def frontend_handler(path: str):
    fp = settings.STATIC_DIR / path
    if not fp.exists() or not fp.is_file():
        fp = settings.STATIC_DIR / "index.html"
    return FileResponse(fp)

app.py

# api interface start
app.include_router(system.router)
# Write multiple api interfaces here
#api interface end

# Note, very important, that this is done after all routes have been added!
app.include_router(static.router)

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by InfernalAzazel
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant