cost 225 ms
Fastapi Testclient 无法使用表单数据发送 POST 请求 - Fastapi Testclient not able to send POST request using form-data

目前我正在使用from fastapi.testclient import TestClient在 Fastapi 中进行单元测试 当我运行 fastapi 应用程序但无法继续进行单元测试时,我应该得到令牌作为响应。 postman 请求的示例 如何确保表单数据是从 TestClient 发送的? ...

如何接收 URL 文件作为参数并使用 FastAPI 将其保存到磁盘? - How to receive URL File as parameter and save it to disk using FastAPI?

我想知道是否有办法让 FastAPI 接收一个文件的 URL 作为参数并将这个文件保存到磁盘? 我知道requests库可以使用requests.get()方法,但是 FastAPI 可以接收 URL 并直接保存吗? 我尝试使用file: UploadFile = File(...) ,但是当发送 ...

为什么 url_for 生成 URL 以 localhost 作为主机名而不是域名? - Why url_for generates URL with localhost as the hostname instead of the domain name?

我有一个使用 Jinja2 模板的 FastAPI web 应用程序,它在localhost上运行良好,但在生产环境中运行不正常。 问题是没有正确生成 JavaScript 和其他static文件的 URL。 我已经使用gunicorn和nginx将它部署在 EC2 实例上。 我的 HTML 文件 ...

Starlette - 类型错误:FormData object 不可调用 - Starlette - Type Error: FormData object is not callable

我正在将音频文件上传到 Starlette 服务器,并尝试按照他们在文档中推荐的方式访问它,但它给了我一个不可调用的错误。 我收集到的问题是根据request object 调用.form() ,但我不确定如何读取它。 服务器路由:@app.route('/api/upload_track/', m ...

如何使用 FastAPI/Starlette 在 RedirectResponse 中添加正文内容? - How to add body content in RedirectResponse using FastAPI/Starlette?

我想在/check_base端点内使用音频文件。 但是,我无法在RedirectResponse的正文中发送文件。 /check端点返回一个RedirectResponse ,它只接受一个URL参数。 请帮我解决这个问题。 这是我的代码:@router.post("/check") async ...

如何通过单击 Jinja2 模板中的 HTML 按钮来浏览 FastAPI 路由? - How to navigate through FastAPI routes by clicking on HTML button in Jinja2 Templates?

如果我手动移动它们(通过更改浏览器地址栏中的/<path> ),我有一个 FastAPI 应用程序,其中一些路由工作正常。 例如,这是其中之一:@task.get('/tasks', response_model=list[Task], tags=["Tasks"]) def find ...

如何在 CORS FastAPI 中间件中正确使用 Regex? - How to properly use Regex in CORS Middleware for FastAPI?

我有一个使用 FastAPI 后端和 Next.js 前端的应用程序。 在具有稳定来源的开发和生产中,我能够毫无问题地使用 CORSMiddleware。 但是,我已经使用 Vercel 部署了 Next.js 前端,并希望利用 Vercel 对每个 git 提交进行的自动预览部署,以允许进行阶段 ...

使用 FastAPI 向 APIRouter 的每个路由注入参数 - Inject parameter to every route of an APIRouter using FastAPI

使用 FastAPI 的APIRouter ,我知道您可以通过dependencies参数传递依赖项。 我看到的每个示例都有一个不返回任何内容的依赖项。 我一直在研究代码,但我猜我不明白如何做我想做的事,知道那是不可能的; 我总是可以将依赖项添加到每条路线。 我想做这样的事情,通过get_permi ...

如何让logstash监听python应用运行的特定端口 - How to make logstash listen to a specific port where the python application is running

我正在尝试让 logstash 管道监听我正在运行我的 python starlette 应用程序的端口 8003。我需要收集日志并将其传递给弹性数据库。 我的 logstash.conf 文件是 还有运行我的 starlette 应用程序的日志 在运行我的 conf 文件后,我在 logstash ...


 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM