1

Below is my code.

@app.post("/")
async def main(user: schemas.UserCreate, db: Session = Depends(get_db)):
    db_user = crud.get_user_by_email(db, email=user.email)
    if db_user:
        return RedirectResponse(url = '/exist',status_code=302)
    crud.create_user(db=db,user=user)
    return RedirectResponse(url='/', status_code=302)


@app.get('/exist')
async def exist():
    return {'message' : "already exist"}

I check network and the Redirect Response itself works fine. enter image description here However, the url on the page remains the same as the current page.

I want to change url to "/exist", How can I do this?

Chris
  • 18,724
  • 6
  • 46
  • 80
helloworld
  • 149
  • 7
  • 2
    It really matters how you perform the `POST` request to `/`, whether you are using Swagger UI or your own JS function, or a simple HTML `
    `. Please have a look at some related answers [here](https://stackoverflow.com/a/70777217/17865804), [here](https://stackoverflow.com/a/73088816/17865804) and [here](https://stackoverflow.com/a/73608593/17865804).
    – Chris Sep 08 '22 at 11:54
  • Yes It was `POST` matters Thank you. – helloworld Sep 17 '22 at 14:02

0 Answers0