Is there a way to do something like this using FastAPI:
<code>@app.post("/instance/new", tags=["instance"])
async def MyFunction(condition):
if condition:
response = {"key": "value"}
return response
else:
return some_big_plein_text
</code>
<code>@app.post("/instance/new", tags=["instance"])
async def MyFunction(condition):
if condition:
response = {"key": "value"}
return response
else:
return some_big_plein_text
</code>
@app.post("/instance/new", tags=["instance"])
async def MyFunction(condition):
if condition:
response = {"key": "value"}
return response
else:
return some_big_plein_text
The way it is coded now, the JSON is returned fine, but some_big_plein_text
is not human friendly. If do: @app.post("/instance/new", tags=["instance"], PleinTextResponse)
I got an error when the return is a JSON.