Python Forum

Full Version: How to take input in POST call from aother pthon file
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi I am trting to execute a scenerio in which cleint make a call to web server and revceived the data and then post it into another server. I am using centos 7 in that I have configured DJANGO web frame work to get my python files executed in HTTP and can be visible in browser. I have done that successfully. Now my problem is that I am Posting my client code to my internal server as below,


#Python 2.7.6
#RestfulClient.py

import requests
from requests.auth import HTTPDigestAuth
import xml



# POST BLOCK...........................................START#

url = 'xyx.com'
payload = {'host_name':'POSTme','address':'192.168.150.17','check_command':'check_ping\!3000,80%\!5000,100%','max_check_attempts':'2','check_period':'24x7','contacts':'admin','notification_interval':'5','notification_period':'24x7','applyconfig':'1'}

r = requests.post(url, data=payload)

#r.text
#r.status_code

if(r.ok):

       print ("Response: "+ r.content);

else:

# If response code is not ok (200), print the resulting http error code with description
   r.raise_for_status()

# POST BLOCK...........................................STOP#

Now I want that the Payload data should be supplied from other file to this client code . Means when I run client code the client should go n take input from other file and fill the"payload " section in this code and run it.it should be lke client ask server for input and then fetch that input in its code and execute it to the server.

Please help!!!!!

Thanks