Created
March 9, 2014 04:59
-
-
Save taoso/9443108 to your computer and use it in GitHub Desktop.
套接字提交POST请求发送报警信息
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
import socket | |
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM); | |
s.connect(('192.168.8.20', 3000)) | |
m = '{"username":"test20","message":"测试"}' | |
mp = ( | |
"POST /notice HTTP/1.0\r\n" | |
"Content-Type:application/json\r\n" | |
"Content-Length:{}\r\n" | |
"\r\n" | |
"{}".format(len(m), m)) | |
s.sendall(mp) | |
s.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment