Well last night I decided to play around with a bit of Python. Now since it is possible to write a fully functional client/server p2p file sharing program in Python in 14 lines, Boyter decided that I could write a webserver in 7. So I spent a couple of hours and this is what I came up with:
from BaseHTTPServer import *
class m(BaseHTTPRequestHandler):
def do_GET(s):
f=open("./"+s.path,'rb')
s.wfile.write(f.read())
return
s=HTTPServer(('',80),m).serve_forever()
Basically, it will serve any file to whoever requests it, doesn't give out File Not Found errors, can't handle forms and doesn't actually close the files it reads in. Ever. Oh, and I think it's probably possible that it opens every file on your system up for reading. Ooops. But yes, it works as a webserver, and it occupies 7 lines and 179 bytes. So that was my achievement. I think Boyter and I should do challenges, trying to make crazy programs like the one above. Oh wait, I have other things to do with my life...
I think...
Recent comments