Python Forum
How to take input in POST call from aother pthon file
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to take input in POST call from aother pthon file
#1
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
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Reading an Input File DaveG 1 1,248 Mar-27-2022, 02:08 AM
Last Post: deanhystad
  how do i store then call a mp3 from sqlite3 .db file gr3yali3n 3 5,726 Dec-11-2020, 10:28 AM
Last Post: snippsat
  subprocess call cannot find the file specified RRR 6 16,572 Oct-15-2020, 11:29 AM
Last Post: RRR
  How to assign input file name as logger name Mekala 5 2,843 Aug-05-2020, 12:54 AM
Last Post: Larz60+
  Call a python file with anothr python file skaailet 3 2,305 Apr-30-2020, 03:41 PM
Last Post: deanhystad
  Call a .xlsx file outside a class criscferr 2 1,861 Apr-24-2020, 04:23 PM
Last Post: criscferr
  Split and sort input file aawaleh 4 2,982 Apr-10-2020, 09:59 PM
Last Post: aawaleh
  User Input and CSV File Davy_Jones_XIV 2 4,806 Mar-24-2020, 08:43 AM
Last Post: Davy_Jones_XIV
  what would you call the input for the parameter(s) of a function you have defined? rix 3 2,450 Dec-16-2019, 12:04 AM
Last Post: rix
  Pytest API Post call thrown errors pyseeker 4 3,619 Dec-08-2019, 04:53 PM
Last Post: pyseeker

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020