Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

POST request : Error 500 Internal Server Error #59

Closed
bsimmo opened this issue Mar 5, 2020 · 7 comments
Closed

POST request : Error 500 Internal Server Error #59

bsimmo opened this issue Mar 5, 2020 · 7 comments
Labels
bug Something isn't working complexity: low It's easy-peasy! Just need to find some time to do it.... fixed It's fixed!

Comments

@bsimmo
Copy link
Member

bsimmo commented Mar 5, 2020

This started failing some time back, I mentioned it then but forgot all about it.

Can you check if the POST method for list-devices-near works
For me it is failing still and the code has not changed

This abbreviated Python3 code should raise the 500 Server Error and had previously worked.

from urllib import request, parse

api_url = "https://sensors.connectedhumber.org/api.php?action="
no_of_locations = 3
my_location = ( 53.750, -0.395 )

def get_nearest_sensors(my_location, no_of_locations):
    url = str(api_url) + "list-devices-near&count=" + str(no_of_locations)
    data = parse.urlencode({'latitude': my_location[0], 'longitude': my_location[1]}).encode()
    req = request.Request(url, data=data)
    response = request.urlopen(req)
    return response

the_sensors = get_nearest_sensors(my_location, no_of_locations)
@sbrl
Copy link
Collaborator

sbrl commented Mar 5, 2020

Fixed! Now I just need to deploy it.

@sbrl
Copy link
Collaborator

sbrl commented Mar 6, 2020

The fix should be deployed to the beta version, @bsimmo. Perhaps you could test it and confirm that it's fixed?

@sbrl sbrl added bug Something isn't working complexity: low It's easy-peasy! Just need to find some time to do it.... fixed It's fixed! labels Mar 6, 2020
@bsimmo
Copy link
Member Author

bsimmo commented Mar 6, 2020 via email

@BNNorman
Copy link

BNNorman commented Mar 6, 2020

And me - live map is still there

@sbrl
Copy link
Collaborator

sbrl commented Mar 8, 2020

Ack! It shouldn't have done that. It should be fixed now @BNNorman @bsimmo

@BNNorman
Copy link

BNNorman commented Mar 8, 2020

Beta and live maps work for me

@bsimmo
Copy link
Member Author

bsimmo commented Mar 8, 2020

Site is working, but the API list-devices-near is not quite working.

If I asked for 3 locations, I would get three before (as intended)
Now I just get the same one (nearest) three times.

Example Python3 code

import json
from urllib import request, parse

api_url = "http://sensors.connectedhumber.org/beta/api.php?action="

no_of_locations = 3
my_location = ( 53.750, -0.395 )

def get_nearest_sensors( my_location, no_of_locations ):
    url = str( api_url ) + "list-devices-near&count=" + str( no_of_locations )
    data = parse.urlencode( {'latitude': my_location[0], 'longitude': my_location[1]} ).encode()
    req = request.Request( url, data=data )
    response = request.urlopen( req )
    return response

# ------- #
nearest_sensors = json.loads( get_nearest_sensors( my_location, no_of_locations ).read().decode('utf-8') )
print( nearest_sensors )
    
for line in nearest_sensors:
    print( line['id'], line['name'], "is", round( line['distance_actual']*0.000621, 1), "miles away" )
print("----------")

Currently returns

[{'id': 36, 'name': 'CHASW-24AD43-1', 'latitude': 53.75642593, 'longitude': -0.36844245, 'distance_calc': 1886.588853560329, 'last_seen': '2020-03-08 21:32:06', 'distance_actual': 1892.19}, {'id': 36, 'name': 'CHASW-24AD43-1', 'latitude': 53.75642593, 'longitude': -0.36844245, 'distance_calc': 1886.588853560329, 'last_seen': '2020-03-08 21:32:06', 'distance_actual': 1892.19}, {'id': 36, 'name': 'CHASW-24AD43-1', 'latitude': 53.75642593, 'longitude': -0.36844245, 'distance_calc': 1886.588853560329, 'last_seen': '2020-03-08 21:32:06', 'distance_actual': 1892.19}]
36 CHASW-24AD43-1 is 1.2 miles away
36 CHASW-24AD43-1 is 1.2 miles away
36 CHASW-24AD43-1 is 1.2 miles away

Also as an aside, I thought
'distance_calc': 1886.588853560329
field was being removed as 'distance_actual' is the correct geodesic distance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working complexity: low It's easy-peasy! Just need to find some time to do it.... fixed It's fixed!
Projects
None yet
Development

No branches or pull requests

3 participants