integrate frontend with backend
This commit is contained in:
parent
164904b954
commit
88b14b434e
6 changed files with 98 additions and 46 deletions
|
|
@ -21,7 +21,7 @@ def encode_result_view(request: HttpRequest) -> HttpResponse:
|
|||
# TODO: do some nice error display
|
||||
return render(request, 'websiteapp/encode_result.html', {"result": "error"})
|
||||
|
||||
result = encode((lat, lon))
|
||||
result = encode((float(lat), float(lon)))
|
||||
result_str = format_location(result)
|
||||
|
||||
return render(request, 'websiteapp/encode_result.html', {"result": result_str})
|
||||
|
|
@ -34,10 +34,15 @@ def decode_result_view(request: HttpRequest) -> HttpResponse:
|
|||
if loc_str is None:
|
||||
# TODO: do some nice error display
|
||||
result = "error"
|
||||
lat, lon = 0, 0
|
||||
|
||||
else:
|
||||
loc = parse_location(loc_str)
|
||||
(lon, lat) = decode(loc)
|
||||
result = f"{lon},{lat}"
|
||||
try:
|
||||
loc = parse_location(loc_str)
|
||||
(lat, lon) = decode(loc)
|
||||
result = f"{lat},{lon}"
|
||||
except ValueError:
|
||||
result = "ERROR - invalid greggordinate!"
|
||||
lat, lon = 0, 0
|
||||
|
||||
return render(request, 'websiteapp/decode_result.html', {"result": result})
|
||||
return render(request, 'websiteapp/decode_result.html', {"result": result, "lat": lat, "lon": lon})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue