-
-
Save abdo1819/4904ecfd64092a40c95752597c05ccf0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from socket import gethostbyname | |
def get_speed(lat,long,host='evilcar.herokuapp.com'): | |
path = '/speed?'+'lat='+str(lat)+'&long='+str(long) | |
return write_request("",host,path=path) | |
# /speed?lat=0&long=0 | |
def write_request(content_str | |
,host | |
,method="GET" | |
,path="/" | |
,content_type="application/json" | |
,new_line="\n\r" | |
,http_version="HTTP/1.1" | |
): | |
return method+" "+path+" "+http_version+new_line \ | |
+"Host: "+host+new_line \ | |
+"Content-Type: "+content_type+new_line \ | |
+"Content-Length: "+str(len(content_str))+new_line*2 \ | |
+content_str \ | |
+new_line | |
if __name__ == "__main__": | |
print(get_speed(0,0)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment