From eb37aa0cc976f1eb00b93b1c1341c39eb8abdbec Mon Sep 17 00:00:00 2001 From: Alexandre Dulaunoy Date: Mon, 24 Jan 2022 08:51:24 +0100 Subject: [PATCH] new: [mygeolookup] Query on root of the server will give the geo location of the remote IP address doing the query. --- bin/server.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/bin/server.py b/bin/server.py index baec217..dc29894 100644 --- a/bin/server.py +++ b/bin/server.py @@ -62,6 +62,19 @@ class GeoLookup: georesult = q.get(value) ret.append(georesult) georesult['meta'] = meta + georesult['ip'] = value + resp.media = ret + return + + +class MyGeoLookup: + def on_get(self, req, resp): + ret = [] + ips = req.access_route + georesult = q.get(ips[0]) + ret.append(georesult) + georesult['meta'] = meta + georesult['ip'] = ips[0] resp.media = ret return @@ -69,6 +82,7 @@ class GeoLookup: app = falcon.App() app.add_route('/geolookup/{value}', GeoLookup()) +app.add_route('/', MyGeoLookup()) if __name__ == '__main__': with make_server('', 8000, app) as httpd: