I am trying to make a simple server-client interaction with Python using json. But now I have a problem, my .json file does upload, but then on the server-side it is empty.
Can you help me?
import json
import urllib.request
import os
import time
import ftplib
import fileinput
from ftplib import FTP
url = urllib.request.urlopen("http://example.com/path/data.json").read()
rawjson = url.decode("utf-8")
number = input("Bank number: ")
result = json.loads(url)
name = result[number]["name"]
salary = result[number]["salary"]
strsalary = str(salary)
newsalary = input("New salary: ")
os.system("wget http://example.com/path/data.json")
newtext = rawjson.replace(strsalary, newsalary)
textfile = open("data.json", "w")
textfile.write(newtext)
#domain name or server ip:
ftp = FTP('example.com','usr','pswd')
ftp.cwd("/path")
file=open('data.json', 'rb')
ftp.storbinary('STOR data.json', file)
This is the client-side script and I wanted to create a client server interaction via json with a simple webserver not a Python server.