-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

1

2 Answers 2

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')
Sign up to request clarification or add additional context in comments.

Comments

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.