I am making my way through python. Currently, I have a software where users will input some data and based on the data they enter they will get some output. At the moment, the software will be distributed as an exe file for windows users.
What I hope I can do now, is to let the software communicate with me over internet. I want the user input values that they put to be sent to me online. This will allow me to monitor my software performance and improve the service overtime with new releases.
Are there suggestions how to achieve this effeciently and in a relatively easy and straight forward manner?
Thank you in advance!
2 Answers 2
I am using bottle web-framework. Here is simple script for processing POSTed data. POSTed data are written in a terminal and returned to the client (server side):
from bottle import get, post, run, request
import sys
@get('/api') #display information in client browser (not necessary)
def hello():
return "This is api page for processing POSTed messages"
@post('/api')
def api():
print(request.body.getvalue().decode('utf-8'), file=sys.stdout)
return request.body #here is reply to client
run(host='localhost', port=8080, debug=True)
Script for POSTing json data to the script above (client side):
import requests
payload = "Hello World"
url = "localhost:8080/api"
headers = {
'content-type': "application/json",
'cache-control': "no-cache"
}
response = requests.request("POST", url, data=payload, headers=headers)
print(response.text)
1 Comment
Socket integration would be great option as you need your application to be connected to the server for sending or receiving performance or updates.
Below link will guide you on how to develop both client and server side integration using python:
requestsmodule or similar, which will work in a separate thread for not block your program execution oraiohttpin case if you use asyncio. if you wanna make communication-based on TCP or UDP sockets are the way to go also you can check the library (twisted). Another option is to use a WebSockets with thattornadokan help you