mirror of
https://github.com/EDCD/EDDN.git
synced 2025-04-27 21:52:14 +03:00
30 lines
502 B
Python
30 lines
502 B
Python
#!/usr/bin/env python3
|
|
|
|
import json
|
|
import sys
|
|
import urllib3
|
|
|
|
if len(sys.argv) != 2:
|
|
print('test-sender.py <filename>')
|
|
sys.exit(-1)
|
|
|
|
with open(sys.argv[1], 'r') as f:
|
|
# Read from provided file
|
|
msg = f.read()
|
|
|
|
# Fake form-encode it
|
|
msg = 'data=' + msg
|
|
|
|
http = urllib3.PoolManager()
|
|
|
|
# Send that data as a POST body
|
|
r = http.request(
|
|
'POST',
|
|
'https://dev.eddn.edcd.io:4432/upload/',
|
|
body=msg
|
|
)
|
|
|
|
print(f'Response: {r.status!r}')
|
|
print(f'Body:\n{r.data.decode()}\n')
|
|
|