-
Notifications
You must be signed in to change notification settings - Fork 0
/
Handlers.py
32 lines (26 loc) · 946 Bytes
/
Handlers.py
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
import Handle_IO
def handle_GET(request, conn, fullRequest):
'''
handles GET method request
'''
splitRequest = request.split(" ")
with open("PageSrc"+splitRequest[1],"rb") as f:
Handle_IO.send_Page(f.read(),conn, ContentType = Handle_IO.get_ContentType(splitRequest[1]))
def handle_POST(request, conn, fullRequest):
pass
def handle_HEAD(request, conn, fullRequest):
'''
Handles HEAD request
'''
splitRequest = request.split(" ")
with open("PageSrc"+splitRequest[1],"rb") as f:
Handle_IO.send_Header("200 OK",Handle_IO.get_ContentType(splitRequest[1]),len(f.read()),conn)
def handle_PUT(request, con, fullRequest):
pass
def handle_DELETE(request, conn, fullRequest):
pass
def handle_TRACE(request, conn, fullRequest):
'''
send back original packet
'''
Handle_IO.send_Page(fullRequest.encode(),conn, ContentType="message/http")