-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
58 lines (46 loc) · 1.67 KB
/
main.js
File metadata and controls
58 lines (46 loc) · 1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
var Main = function() {
var http = new XMLHttpRequest();
var url = "http://api.justyo.co/yo/";
var params = "api_token=<token>&username=JOE";
http.open("POST", url, true);
//Send the proper header information along with the request
http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
http.setRequestHeader("Content-length", params.length);
http.setRequestHeader("Connection", "close");
http.onreadystatechange = function() {//Call a function when the state changes.
if(http.readyState == 4 && http.status == 200) {
alert(http.responseText);
}
}
http.send(params);
};
$(document).ready(Main);
$.get('http://yoursite.com/test/' + id, function(data) {
console.log(data);
});
def search(term, city, latitude, longitude):
url_params = {
'term': term,
'location': city,
'cll': latitude + ',' + longitude,
'limit': SEARCH_LIMIT,
'sort': 2, # highest rated
'radius_filter': 1600 # one mile
}
return do_request(API_HOST, SEARCH_PATH, url_params=url_params)
import argparse
@app.route("/yo/")
def yo():
username = request.args.get('username')
location = request.args.get('location')
splitted = location.split(';')
latitude = splitted[0]
longitude = splitted[1]
response = requests.get('http://nominatim.openstreetmap.org/reverse?format=json&lat=' + latitude + '&lon=' +longitude + '&zoom=18&addressdetails=1')
response_object = json.loads(response.text)
city = response_object['address']['city']
requests.post("http://api.justyo.co/yo/", data={'api_token': '<your_token>', 'username': username,
return 'OK'
if __name__ == "__main__":
app.debug = True
app.run()