28 lines
734 B
Python
28 lines
734 B
Python
import requests
|
|
import json
|
|
from pathlib import Path
|
|
|
|
# curl "localhost:80/hello_world"
|
|
|
|
avap_code = Path(
|
|
"/home/pseco/VsCodeProjects/assistance-engine/docs/samples/hola_mundo.avap"
|
|
).read_text(encoding="utf-8")
|
|
|
|
response = requests.request(
|
|
"GET",
|
|
"http://localhost:9000/",
|
|
data=avap_code.encode("utf-8"),
|
|
headers={"Content-Type": "text/plain; charset=utf-8", "Accept": "application/json"},
|
|
timeout=30,
|
|
)
|
|
|
|
print("STATUS:", response.status_code)
|
|
print("RAW TEXT:")
|
|
print("HEADERS:", dict(response.headers))
|
|
print("BODY:", response.text)
|
|
try:
|
|
print("\nJSON FORMATEADO:")
|
|
print(json.dumps(response.json(), indent=2, ensure_ascii=False))
|
|
except Exception:
|
|
print("\nLa respuesta no es JSON válido")
|