-2

I've a web server setup in a separate location and I wanted to access it remotely using HTTP POST request. Can someone please guide me how to proceed with it. I need to use Python which runs the HTTP Post request and modifies the contents of the WEB page

2 Answers2

1

Although probably not particularly practical, you could use a socket. A script on the server which receives the POST request would have to modify the desired web pages content upon receipt.

import socket

sock = socket.socket()
sock.connect(('server_domainname.com', 80))
sock.sendall(b'POST / HTTP/1.1\r\nHost: server_domainname.com:80\r\n\r\n')
uname01
  • 1,221
  • 9
  • 9
0

I think the basic idea is to create a connection, build some headers and data, then go ahead and send that request, get the response from the connection, and then you can then read the response.

connection = httplib.HTTPConnection('<yourServerAddress>:<port>')
headers = ... # Some JSON
data = ... # Some data
connection.request('POST', 'resource/name/goes/here', data, headers)
response = connection.getresponse()
# Let's print what we get back
print response.read()

Please see: Python URLLib / URLLib2 POST

Community
  • 1
  • 1
Tr1gZer0
  • 1,482
  • 11
  • 18