File size: 528 Bytes
67819f1
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
import urllib.request
import urllib.error
import json
payload = {'title':'Lão Hạc','content':'Đây là bài văn dùng để thử nghiệm lỗi chấm điểm.'}
data = json.dumps(payload).encode('utf-8')
req = urllib.request.Request('http://127.0.0.1:8000/api/v1/judge', data=data, headers={'Content-Type':'application/json'})
try:
    resp = urllib.request.urlopen(req)
    print(resp.read().decode('utf-8'))
except urllib.error.HTTPError as e:
    print('HTTP', e.code)
    print(e.read().decode('utf-8'))