Question: Modify this code so that it give information of individuals who live in that location if location is found and the location i want is

Modify this code so that it give information of individuals who live in that location if location is found and the location i want is kansas city from xmlrpc.server import SimpleXMLRPCServer
import sys
import json
def load_data(group):
# Load data based on which portion it handles (am or nz)
file_path = f'data-{group}.json'
with open(file_path, 'r') as file:
data = json.load(file)
return data
class Worker:
def __init__(self, group):
self.data = load_data(group)
def getbyname(self, name):
result =[self.data.get(name,{})]
return {'error': False, 'result': result}
def getbylocation(self, location):
result =[]
for person in self.data.values():
if person["location"]== location:
result.append(person)
return {'error': False, 'result': result}
def getbyyear(self, location, year):
result =[record for record in self.data.values() if record['location']== location and record['year']== year]
return {'error': False, 'result': result}
def main():
if len(sys.argv)<3:
print('Usage: worker.py ')
sys.exit(0)
port = int(sys.argv[1])
group = sys.argv[2]
server = SimpleXMLRPCServer(("localhost", port))
print(f"Worker listening on port {port} for group {group}...")
# Register the Worker class instance
server.register_instance(Worker(group))
server.serve_forever()
if __name__=='__main__':
main()

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!