내 연락처 정보
우편메소피아@프로톤메일.com
2024-07-12
한어Русский языкEnglishFrançaisIndonesianSanskrit日本語DeutschPortuguêsΕλληνικάespañolItalianoSuomalainenLatina
- from fastapi import FastAPI, Response
-
- app = FastAPI()
-
-
- # ① xml
- @app.get("/legacy")
- def get_legacy_data():
- data = """<?xml version="1.0"?>
- <shampoo>
- <Header>
- Apply shampoo here.
- </Header>
- <Body>
- You'll have to use soap here.
- </Body>
- </shampoo>
- """
- return Response(content=data, media_type="application/xml")
실제 수익을 살펴보겠습니다.
반환된 유형은 반환이 성공했음을 나타내는 xml 형식입니다.
- @app.get("/legacy_with_headers")
- def get_legacy_with_headers_data():
- headers = {"X-Xtoken": "LC", "Content-Language": "en-US"}
- data = """<?xml version="1.0"?>
- <shampoo>
- <Header>
- Apply shampoo here.
- </Header>
- <Body>
- You'll have to use soap here.
- HERE SOMETHING HEADER YOU DEFINED
- </Body>
- </shampoo>
- """
- return Response(content=data, media_type="application/xml", headers=headers)
실제 수익률을 살펴보겠습니다
해당 인터페이스는 정상적으로 반환될 수 있고, 해당 헤더도 정상적으로 반환될 수 있습니다.
- @app.get("/legacy_with_header_cookie")
- def legacy_with_header_cookie():
- headers = {"X-Xtoken": "LC-1", "Content-Language": "en-US"}
- data = """<?xml version="1.0"?>
- <shampoo>
- <Header>
- Apply shampoo here.
- </Header>
- <Body>
- You'll have to use soap here.
- HERE SOMETHING HEADER YOU DEFINED AND COOKIE
- </Body>
- </shampoo>
- """
- response = Response(content=data, media_type="application/xml", headers=headers)
- response.set_cookie(key="cookie_key_lc", value="mrli")
- return response
실제 수익률을 살펴보겠습니다
인터페이스는 우리가 설정한 쿠키를 정상적으로 반환할 수 있고, 헤더도 정상적으로 반환할 수 있습니다.