我有一个用 fastapi 编写的应用程序,并使用 uvicorn 和 supervisor 部署在 ubuntu 服务器上。该命令uvicorn main:app --host 0.0.0.0 --port 8000
启动应用程序。我可以访问该地址的应用程序
myserver_ip:8000
该应用程序有一个表单, (GET) 显示在
http://myserver_ip:8000/file/
@router.get("/file/")
async def file_receive():
content = """
<body>
<form action = "http://0.0.0.0:8000/image/uploadfile/" enctype="multipart/form-data" method="post">
<input name="file" type="file" multiple>
<input type="submit">
</form>
</body>
"""
return HTMLResponse(content=content)
动作参数是 http://0.0.0.0:8000/image/uploadfile/
但是在表单重定向之后,我没有去页面http://myserver_ip:8000/image/uploadfile/。如果我设置相同的结果action = http://localhost:8000/image/uploadfile/
当然,如果我直接设置动作变量 =http://myserver_ip:8000/image/uploadfile/
一切都开始工作。但是没有办法在本地机器上运行这段代码。如何正确设置重定向?