Add API endpoints for just 3 or just 6 words

This commit is contained in:
mmcwilliams 2024-06-28 15:04:29 -04:00
parent d388791009
commit 44f1bcac33
1 changed files with 18 additions and 2 deletions

20
app.py
View File

@ -52,8 +52,6 @@ def showMapFromLatLng(lat, lng):
# API # API
@get('/api/<lat:float>,<lng:float>') @get('/api/<lat:float>,<lng:float>')
def latLngToHash(lat, lng): def latLngToHash(lat, lng):
print(lat, file=sys.stdout)
print(lng, file=sys.stdout)
try: try:
three = these.three_words((lat,lng,)) three = these.three_words((lat,lng,))
six = these.six_words((lat,lng,)) six = these.six_words((lat,lng,))
@ -62,6 +60,24 @@ def latLngToHash(lat, lng):
print(error, file=sys.stderr) print(error, file=sys.stderr)
return {} return {}
@get('/api/three/<lat:float>,<lng:float>')
def latLngToThreeHash(lat, lng):
try:
three = these.three_words((lat,lng,))
return {'three': three}
except Exception as error:
print(error, file=sys.stderr)
return {}
@get('/api/six/<lat:float>,<lng:float>')
def latLngToSixHash(lat, lng):
try:
six = these.six_words((lat,lng,))
return {'six': six}
except Exception as error:
print(error, file=sys.stderr)
return {}
@get('/api/<threewords>') @get('/api/<threewords>')
def hashToLatLng(threewords): def hashToLatLng(threewords):