Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 | 31 |
Tags
- noise contrast estimation
- Excel
- normalization
- Knowledge Distillation
- model-free control
- checkitout
- rest-api
- objective functions for machine learning
- shadowing
- scowl
- Policy Gradient
- straightup
- loss functions
- domain adaptation
- REINFORCE
- sample rows
- sidleup
- clip intensity values
- Actor-Critic
- MRI
- resample
- 자료구조
- thresholding
- freebooze
- non parametic softmax
- 3d medical image
- remove outliers
- Inorder Traversal
- pulloff
- fastapi
Archives
- Today
- Total
Let's Run Jinyeah
[Python] Consuming APIs 본문
HTTP library - requests
- make and send HTTP request to interact with APIs
- GET / POST / PUT / DELETE
import requests
# GET : url에 특정 id
api_url = "https://jsonplaceholder.typicode.com/todos/10"
response = requests.get(api_url)
print(response.json())
print(response.status_code)
print(response.headers["Content-Type"]) #metatdata about the response
# POST: 전체 todos url 사용
api_url = "https://jsonplaceholder.typicode.com/todos"
todo = {"userId": 1, "title": "Buy milk", "completed": False}
response = requests.post(api_url, json=todo)
print(response.json())
print(response.status_code) # 201: new resource was created
# PUT: 특정 id 수정위해 url에 특정 id 지정
api_url = "https://jsonplaceholder.typicode.com/todos/10"
todo = {"userId": 1, "title": "Wash car", "completed": True}
response = requests.put(api_url, json=todo)
print(response.json())
print(response.status_code)
'Programming > Web' 카테고리의 다른 글
[FastAPI] Build APIs (0) | 2021.11.19 |
---|---|
Build REST APIs (0) | 2021.11.19 |
REST API (0) | 2021.11.19 |
[Error]CSS style 변경 후 웹브라우저에 반영이 안되는 경우 (0) | 2021.01.15 |
웹 서버란? (0) | 2021.01.07 |
Comments