Skip to main content
Commonmark migration
Source Link

##Python 2, 525 510 493 (bending the rules 483) chars from socket import* from os.path import* a=socket(2,1) a.bind(("",80)) a.listen(5) while 1: c,_=a.accept();i=c.recv(512).split("\n")[0].split();z=i[1][1:];m=i[2]+(i[0]!="GET"and"405 Not Supported\n\n"*2or exists(z)-1and"404 File Not Found\n\n"*2or"200 OK\n") if(len(m)>16)+isdir(z)<1: try:f=open(z,"rb");m+="Content-Type: "+{".txt":"text/plain","html":"text/html"}.get(z[-4:],"application/octet-stream")+"\n\n"+f.read() except:m=i[2]+"500 Server Error\n\n"*2 c.send(m);c.close()

Python 2, 525 510 493 (bending the rules 483) chars

from socket import* from os.path import* a=socket(2,1) a.bind(("",80)) a.listen(5) while 1: c,_=a.accept();i=c.recv(512).split("\n")[0].split();z=i[1][1:];m=i[2]+(i[0]!="GET"and"405 Not Supported\n\n"*2or exists(z)-1and"404 File Not Found\n\n"*2or"200 OK\n") if(len(m)>16)+isdir(z)<1: try:f=open(z,"rb");m+="Content-Type: "+{".txt":"text/plain","html":"text/html"}.get(z[-4:],"application/octet-stream")+"\n\n"+f.read() except:m=i[2]+"500 Server Error\n\n"*2 c.send(m);c.close() 

I stated that I only need 483 chars if I bend the rules because the last ;c.close() could be omitted. This is because the moment the next client gets accepted, the socket gets closed anyway. This will of course increase waiting time somewhat (Firefox will only display the page when the next client connects, Chrome will display it before, but will continue to load), but the rules do not require me to respond to the request immediately, only to do so at some point.

I am not certain whether this will work on Unixes because I used send instead of sendall and send does not guarantee to actually send everything it is fed. It does work on Windows.

The screenshot that doesn't proof anything because there is no way to tell whether I used Apache or my own server to create it

##Python 2, 525 510 493 (bending the rules 483) chars from socket import* from os.path import* a=socket(2,1) a.bind(("",80)) a.listen(5) while 1: c,_=a.accept();i=c.recv(512).split("\n")[0].split();z=i[1][1:];m=i[2]+(i[0]!="GET"and"405 Not Supported\n\n"*2or exists(z)-1and"404 File Not Found\n\n"*2or"200 OK\n") if(len(m)>16)+isdir(z)<1: try:f=open(z,"rb");m+="Content-Type: "+{".txt":"text/plain","html":"text/html"}.get(z[-4:],"application/octet-stream")+"\n\n"+f.read() except:m=i[2]+"500 Server Error\n\n"*2 c.send(m);c.close()

I stated that I only need 483 chars if I bend the rules because the last ;c.close() could be omitted. This is because the moment the next client gets accepted, the socket gets closed anyway. This will of course increase waiting time somewhat (Firefox will only display the page when the next client connects, Chrome will display it before, but will continue to load), but the rules do not require me to respond to the request immediately, only to do so at some point.

I am not certain whether this will work on Unixes because I used send instead of sendall and send does not guarantee to actually send everything it is fed. It does work on Windows.

The screenshot that doesn't proof anything because there is no way to tell whether I used Apache or my own server to create it

Python 2, 525 510 493 (bending the rules 483) chars

from socket import* from os.path import* a=socket(2,1) a.bind(("",80)) a.listen(5) while 1: c,_=a.accept();i=c.recv(512).split("\n")[0].split();z=i[1][1:];m=i[2]+(i[0]!="GET"and"405 Not Supported\n\n"*2or exists(z)-1and"404 File Not Found\n\n"*2or"200 OK\n") if(len(m)>16)+isdir(z)<1: try:f=open(z,"rb");m+="Content-Type: "+{".txt":"text/plain","html":"text/html"}.get(z[-4:],"application/octet-stream")+"\n\n"+f.read() except:m=i[2]+"500 Server Error\n\n"*2 c.send(m);c.close() 

I stated that I only need 483 chars if I bend the rules because the last ;c.close() could be omitted. This is because the moment the next client gets accepted, the socket gets closed anyway. This will of course increase waiting time somewhat (Firefox will only display the page when the next client connects, Chrome will display it before, but will continue to load), but the rules do not require me to respond to the request immediately, only to do so at some point.

I am not certain whether this will work on Unixes because I used send instead of sendall and send does not guarantee to actually send everything it is fed. It does work on Windows.

The screenshot that doesn't proof anything because there is no way to tell whether I used Apache or my own server to create it

deleted 148 characters in body
Source Link
cemper93
  • 700
  • 5
  • 8

##Python 2, 525 510 510493 (bending the rules 500483) chars from socket import* from os.path import* a,h=socketa=socket(2,1),"HTTP/1.0 " a.bind(("",80)) a.listen(5) while 1: c,_=a.accept();i=c.recv(4096512).split("\n")[0].split();z=i[1][1:];m=h+];m=i[2]+(i[0]!="GET"and"405 Not Supported\n\n"*2 orSupported\n\n"*2or exists(z)-1 and"4041and"404 File Not Found\n\n"*2 or"200Found\n\n"*2or"200 OK\n") if(len(m)>16)+isdir(z)<1: try:f=open(z,"rb");m+="Content-Type: "+{".txt":"text/plain","html":"text/html"}.get(z[-4:],"application/octet-stream")+"\n\n"+f.read() except:m=h+"500m=i[2]+"500 Server Error\n\n"*2 c.sendallsend(m);c.close() I think this implements everything that is asked, though I'm not certain that there are not bugs. I have no idea how to trigger a 500 Server Error and am too lazy to trigger a 405 Not Supported manually. 

I stated that I only need 515483 chars if I bend the rules because the last ;c.close() could be omitted. This is because the moment the next client gets accepted, the socket gets closed anyway. This will of course increase waiting time somewhat (Firefox will only display the page when the next client connects, Chrome will display it before, but will continue to load), but the rules do not require me to respond to the request immediately, only to do so at some point.
BTW: 

I didn't use any pre-made TCP servers even though Python has one in the standard libraryam not certain whether this will work on Unixes because that's lameI used send instead of sendall and send does not guarantee to actually send everything it is fed. It does work on Windows.

The screenshot that doesn't proof anything because there is no way to tell whether I used Apache or my own server to create it

##Python 2, 525 510 (bending the rules 500) chars from socket import* from os.path import* a,h=socket(2,1),"HTTP/1.0 " a.bind(("",80)) a.listen(5) while 1: c,_=a.accept();i=c.recv(4096).split("\n")[0].split();z=i[1][1:];m=h+(i[0]!="GET"and"405 Not Supported\n\n"*2 or exists(z)-1 and"404 File Not Found\n\n"*2 or"200 OK\n") if(len(m)>16)+isdir(z)<1: try:f=open(z,"rb");m+="Content-Type: "+{".txt":"text/plain","html":"text/html"}.get(z[-4:],"application/octet-stream")+"\n\n"+f.read() except:m=h+"500 Server Error\n\n"*2 c.sendall(m);c.close() I think this implements everything that is asked, though I'm not certain that there are not bugs. I have no idea how to trigger a 500 Server Error and am too lazy to trigger a 405 Not Supported manually. I stated that I only need 515 chars if I bend the rules because the last ;c.close() could be omitted. This is because the moment the next client gets accepted, the socket gets closed anyway. This will of course increase waiting time somewhat (Firefox will only display the page when the next client connects, Chrome will display it before, but will continue to load), but the rules do not require me to respond to the request immediately, only to do so at some point.
BTW: I didn't use any pre-made TCP servers even though Python has one in the standard library because that's lame.

The screenshot that doesn't proof anything because there is no way to tell whether I used Apache or my own server to create it

##Python 2, 525 510 493 (bending the rules 483) chars from socket import* from os.path import* a=socket(2,1) a.bind(("",80)) a.listen(5) while 1: c,_=a.accept();i=c.recv(512).split("\n")[0].split();z=i[1][1:];m=i[2]+(i[0]!="GET"and"405 Not Supported\n\n"*2or exists(z)-1and"404 File Not Found\n\n"*2or"200 OK\n") if(len(m)>16)+isdir(z)<1: try:f=open(z,"rb");m+="Content-Type: "+{".txt":"text/plain","html":"text/html"}.get(z[-4:],"application/octet-stream")+"\n\n"+f.read() except:m=i[2]+"500 Server Error\n\n"*2 c.send(m);c.close() 

I stated that I only need 483 chars if I bend the rules because the last ;c.close() could be omitted. This is because the moment the next client gets accepted, the socket gets closed anyway. This will of course increase waiting time somewhat (Firefox will only display the page when the next client connects, Chrome will display it before, but will continue to load), but the rules do not require me to respond to the request immediately, only to do so at some point. 

I am not certain whether this will work on Unixes because I used send instead of sendall and send does not guarantee to actually send everything it is fed. It does work on Windows.

The screenshot that doesn't proof anything because there is no way to tell whether I used Apache or my own server to create it

added 1 characters in body
Source Link
cemper93
  • 700
  • 5
  • 8

##Python 2, 525525 510 (bending the rules 515500) chars from socket import* from os.path import* a,h=socket(2,1),"HTTP/1.0 " a.bind(("",80)) a.listen(5) while 1: c,_=a.accept() i=c;i=c.recv(4096).split("\n")[0].split() z=i[1][1;z=i[1][1:] m=h+];m=h+(i[0]!="GET"and"405 Not Supported\n\n"*2 or exists(z)-1 and"404 File Not Found\n\n"*2 or"200 OK\n") if(len(m)>16)+isdir(z)<1: try:f=open(z,"rb");m+="Content-Type: "+{"txt"".txt":"text/plain","html":"text/html"}.get(z.split(".")[z[-1]4:],"application/octet-stream")+"\n\n"+f.read() except:m=h+"500 Server Error\n\n"*2 c.sendall(m);c.close()

I I think this implements everything that is asked, though I'm not certain that there are not bugs. I have no idea how to trigger a 500 Server Error and am too lazy to trigger a 405 Not Supported manually. I stated that I only need 515 chars if I bend the rules because the last ;c.close() could be omitted. This is because the moment the next client gets accepted, the socket gets closed anyway. This will of course increase waiting time somewhat (Firefox will only display the page when the next client connects, Chrome will display it before, but will continue to load), but the rules do not require me to respond to the request immediately, only to do so at some point.
BTW: I didn't use any pre-made TCP servers even though Python has one in the standard library because that's lame.

The screenshot that doesn't proof anything because there is no way to tell whether I used Apache or my own server to create it

##Python 2, 525 (bending the rules 515) chars from socket import* from os.path import* a,h=socket(2,1),"HTTP/1.0 " a.bind(("",80)) a.listen(5) while 1: c,_=a.accept() i=c.recv(4096).split("\n")[0].split() z=i[1][1:] m=h+(i[0]!="GET"and"405 Not Supported\n\n"*2 or exists(z)-1 and"404 File Not Found\n\n"*2 or"200 OK\n") if(len(m)>16)+isdir(z)<1: try:f=open(z,"rb");m+="Content-Type: "+{"txt":"text/plain","html":"text/html"}.get(z.split(".")[-1],"application/octet-stream")+"\n\n"+f.read() except:m=h+"500 Server Error\n\n"*2 c.sendall(m);c.close()

I think this implements everything that is asked, though I'm not certain that there are not bugs. I have no idea how to trigger a 500 Server Error and am too lazy to trigger a 405 Not Supported manually. I stated that I only need 515 chars if I bend the rules because the last ;c.close() could be omitted. This is because the moment the next client gets accepted, the socket gets closed anyway. This will of course increase waiting time somewhat (Firefox will only display the page when the next client connects, Chrome will display it before, but will continue to load), but the rules do not require me to respond to the request immediately, only to do so at some point.
BTW: I didn't use any pre-made TCP servers even though Python has one in the standard library because that's lame.

The screenshot that doesn't proof anything because there is no way to tell whether I used Apache or my own server to create it

##Python 2, 525 510 (bending the rules 500) chars from socket import* from os.path import* a,h=socket(2,1),"HTTP/1.0 " a.bind(("",80)) a.listen(5) while 1: c,_=a.accept();i=c.recv(4096).split("\n")[0].split();z=i[1][1:];m=h+(i[0]!="GET"and"405 Not Supported\n\n"*2 or exists(z)-1 and"404 File Not Found\n\n"*2 or"200 OK\n") if(len(m)>16)+isdir(z)<1: try:f=open(z,"rb");m+="Content-Type: "+{".txt":"text/plain","html":"text/html"}.get(z[-4:],"application/octet-stream")+"\n\n"+f.read() except:m=h+"500 Server Error\n\n"*2 c.sendall(m);c.close() I think this implements everything that is asked, though I'm not certain that there are not bugs. I have no idea how to trigger a 500 Server Error and am too lazy to trigger a 405 Not Supported manually. I stated that I only need 515 chars if I bend the rules because the last ;c.close() could be omitted. This is because the moment the next client gets accepted, the socket gets closed anyway. This will of course increase waiting time somewhat (Firefox will only display the page when the next client connects, Chrome will display it before, but will continue to load), but the rules do not require me to respond to the request immediately, only to do so at some point.
BTW: I didn't use any pre-made TCP servers even though Python has one in the standard library because that's lame.

The screenshot that doesn't proof anything because there is no way to tell whether I used Apache or my own server to create it

Source Link
cemper93
  • 700
  • 5
  • 8
Loading