Skip to content

Instantly share code, notes, and snippets.

@abdo1819
Forked from ak-seyam/requester.py
Last active January 31, 2020 19:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abdo1819/4904ecfd64092a40c95752597c05ccf0 to your computer and use it in GitHub Desktop.
Save abdo1819/4904ecfd64092a40c95752597c05ccf0 to your computer and use it in GitHub Desktop.
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