I have some code running on my Raspberry Pi (client running Python) that gets my public IP-address every hour. Now I want my IP to send that string to App Engine datastore.
Unfortunatly I do not know how to post data from a client, and all the examples I tried to google seems to handle browser inputs, not posting with Python from a client.
Does anyone know a good tutorial, or have some example code that a novice like me can understand? Maybe some pointers?
You just need to send your data as an HTTP POST. As Tim says in the comments, the third-party requests library is a great way to do this, although you can do it with the built-in urllib2.
From the server point of view, getting data from a POST like this is exactly the same as getting it from a form submission.
Related
This is my first post. I tried to google and find my own solution, but I don’t even know where to start with this. I want to make a phone app (with Unity(C#) ideally) and eventually a website, while also hosting a web app (python) that the phone app can send basic info (ideally a json or dict) that the web app can do some processing and database referencing and just send back a short answer or two (again ideally a json or dict). I looked into bottlepy and just communicating through http but this seems clunky and I’m sure is not the best way. I don't need (although would appreciate) a full explanation, just the term/protocol/technology I am looking for. Thanks in advance for any help!
You should look at the UnityWebRequest : https://docs.unity3d.com/Manual/UnityWebRequest.html
And maybe you should try to use a REST API on your server to communicate with a UnityWebRequest : https://codetolight.wordpress.com/2017/01/18/unity-rest-api-interaction-with-unitywebrequest-and-besthttp/
I am only told to create a pythonic web service. At the end of the day, I need to offer a HTTPS endpoint which will receive(from a post request), and be able to process/send back json objects from/to another web service.
To be able to receive post requests from other services, what kind of information do I need?
I have seen some examples using httplib2 such as sending HTTP get and post requests when given a website like www.something.com. But in my case, since I do not know the IP address/URL of the data source, should I create a listener waiting for the incoming data? How to achieve this?
I am really new with building python web server and the requirement I am given is really vague. Thank you in advance for helping me break down this problem.
Take a look at the Flask framework, it can do everything you want and then some. I can especially recommend the Quickstart: A Minimal Application and the JSON Support pages.
Enabling the build in debugger will help you a great deal as well.
All services is listening for incoming connections, so you are right about that :-)
Good luck!
I have an Arducam OV2640
There is a lot of documentation on how the code works wth a HTML and js script which calls the camera IP address, after arducam creates a web server.
This web server listens to get requests and sends a post response of the image.
The only problem is this is all over local wifi...source:
https://github.com/ArduCAM/Arduino/tree/master/ArduCAM/examples/ESP8266/ArduCAM_ESP8266_OV2640_Capture
Has anyone done anything such as sending to Imgur via api or for instance a cloud based program like python anywhere?
I've been trying different methods all day, but a lot it comes to people saying "you need to send each byte and the other side have a handler."
I'm asking because the local wifi method works so easily I thought there must be a way to extend this to external addresses in a nicer way?
Has anyone done or heard of anything like this?
Thanks
I’m trying to learn sockjs for a small university project.
I’ve a local server (with typical LAMP configuration), my goal is writing a python script (running on my local server) that is able to send data to client browser in order to update a text information.
Sockjs was seemed to me the best solution (tornado-sockjs for python server).
I read the tutorial examples (https://github.com/mrjoes/sockjs-tornado/tree/master/examples) but I’ve difficult to understand the basic functions.
It would be very useful to understand an example code. An example could be:
A python-server script generates a random number each 5 seconds and send this number to client. In webpage there is a definite element to update this value.
In the same webpage there is a button to send a text message to python server. When python server received this message, print it in the server console.
Thank you in advance for your help.
I hope that this post will be useful to other people.
I am working on trying to send XML data to a .NET web service, from an Asterisk Linux box, using Python.
The problems I am running into are:
-- if I use HTTPlib, I can send the XML data; but, the not authenticate first.
-- if I use HTTPlib2, I can authenticate; but, I can't get it to send the data.
In the end, I just need to periodically send data to a client's web service. On my end, I'm not concerned with the response, just sending the data.
Any thoughts on this? Maybe I'm pursuing the wrong path using HTTPlib? Thanks for any assistance at all. I'm not opposed to using a different language; Python just seemed the simplest when this project started.
A very popular module for this is
http://docs.python-requests.org/en/latest/
works great for me for all sorts of requests with and without authentication.