LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 11-02-2019, 04:32 PM   #1
shogun1234
Member
 
Registered: May 2004
Posts: 226

Rep: Reputation: 15
Python stream post data


I have a python script that I want to stream sending json to the server side.

The script code follows the example https://requests.kennethreitz.org/en...eaming-uploads and its code looks like

Code:
#!/usr/bin/env python3

import requests

url = "http://localhost:8888/streaming_test"

with open("/path/to/data.json", 'rb') as fs:
  req = requests.post(url, data=fs)
  print(req)
  print(req.text)
But it throws error ValueError: invalid literal for int() with base 16: b''


What goes wrong? How can I fix that? Thanks
 
Old 11-02-2019, 06:10 PM   #2
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 11,226

Rep: Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320
Does "/path/to/data.json" actually contain valid JSON? Have you checked it for errors?

You can just paste it into https://jsonlint.com/ and it will tell you. I use a program called Prettier to check JSON files for validity.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Monitoring data passing on USB bus & copying data (dumping) to hard drive (forking an identical data stream) cilbuper Programming 4 12-11-2017 01:58 PM
LXer: Python Python Python (aka Python 3) LXer Syndicated Linux News 0 08-05-2009 08:30 PM
program to stream the stream (or maybe streaming proxy?) jimmykarily Linux - Software 1 05-13-2009 04:35 AM
How to record a stream and start a new outputXXX.avi/mp3 for each new stream title ? frenchn00b Linux - General 4 08-04-2008 05:40 AM
Howto transcode & relay a MPEG stream to a WMV stream?? crazyivan Linux - Software 0 06-15-2007 03:18 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:58 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration