简体   繁体   English

fastAPI 返回内容类型“应用程序/液体”

[英]fastAPI returning content-type 'application/liquid'

I have a custom search algorithm API for a shopify store.我有一个 shopify 商店的自定义搜索算法 API。 The API perfectly receives calls and processes them. API 完美地接收调用并处理它们。 However, I need to return a liquid formatted response for shopify to integrate my response properly to its theme.但是,我需要为 shopify 返回一个液体格式的响应,以便将我的响应正确地集成到它的主题中。 I'm using fast API to return a response.我正在使用快速 API 来返回响应。 Does anyone know how I can properly return liquid content to shopify?有谁知道我怎样才能正确地将液体内容退回到shopify?

In FastAPI you can return a custom response like this:在 FastAPI 中,您可以返回如下自定义响应:

from fastapi import FastAPI, Response

app = FastAPI()


@app.get("/search/")
def shopify_search():
    return Response(content="SearchResults", media_type="application/liquid")

Source: the extensive documentation for FastAPI来源: FastAPI 的大量文档

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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