Beispiel #1
0
def get_infected_info():
	client = pymongo.MongoClient(mongo_info.connection_url)
	db = client.covid.daily
	dataset = db.find({})

	output = []

	for val in dataset:
		output.append(val)


	json_out = JSONEncoder().encode(output)

	pprint(json_out)

	return json_out
Beispiel #2
0
    def get(self):

        # 1 Get Url params
        name = request.args.get('name')

        # 2 Our users users collection
        users_collection = template.db.users

        # 3 Find document in users collection
        result = users_collection.find_one(
            {'name': name}
        )

        # 4 Convert result to json from python dict
        json_result = JSONEncoder().encode(result)
        pdb.set_trace()
        # 5 Return json as part of the response body
        return (json_result, 200, None)
Beispiel #3
0
def get_sites_data():
    sites = Sites.get_sites_from_db()
    return JSONEncoder().encode(sites)
Beispiel #4
0
 def to_json(self):
     """Encode robot model as JSON."""
     encoder = JSONEncoder(sort_keys=True)
     return encoder.encode(self)
Beispiel #5
0
def output_json(data, code, headers=None):
    resp = make_response(JSONEncoder().encode(data), code)
    resp.headers.extend(headers or {})
    return resp
Beispiel #6
0
 def find_all(self):
     return JSONEncoder().encode(self.flightsRepo.find_all())
Beispiel #7
0
 def delete(self, flightRequestId):
     deletedFlightId = self.flightsRepo.delete(flightRequestId)
     return JSONEncoder().encode({"_id": deletedFlightId})
Beispiel #8
0
 def insert(self, flightRequest):
     insertedFlightId = self.flightsRepo.insert(flightRequest)
     return JSONEncoder().encode({"_id": insertedFlightId})