forked from sangge/tpre-python
feat: add client_cli
This commit is contained in:
parent
448f20c9df
commit
7977557fc4
23
src/client_cli.py
Normal file
23
src/client_cli.py
Normal file
@ -0,0 +1,23 @@
|
||||
import argparse
|
||||
import requests
|
||||
|
||||
def send_post_request(ip_addr, message_name):
|
||||
url = f"http://localhost:20234/request_message/?i_m"
|
||||
data = {
|
||||
"dest_ip": ip_addr,
|
||||
"message_name": message_name
|
||||
}
|
||||
response = requests.post(url, json=data)
|
||||
return response.text
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description="Send POST request to a specified IP.")
|
||||
parser.add_argument("ip_addr", help="IP address to send request to.")
|
||||
parser.add_argument("message_name", help="Message name to send.")
|
||||
|
||||
args = parser.parse_args()
|
||||
response = send_post_request(args.ip_addr, args.message_name)
|
||||
print(response)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
Loading…
x
Reference in New Issue
Block a user