Skip to content

Instantly share code, notes, and snippets.

@merrymercy
Created March 21, 2023 00:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save merrymercy/d7309af801dd3cfcb4f895368fd3dffa to your computer and use it in GitHub Desktop.
Save merrymercy/d7309af801dd3cfcb4f895368fd3dffa to your computer and use it in GitHub Desktop.
Permanently redirect to another url.
from fastapi import FastAPI
from starlette.responses import RedirectResponse
app = FastAPI()
@app.get("/")
async def redirect():
response = RedirectResponse(url="https://alpa-projects.github.io/opt", status_code=301)
return response
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment