Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import socket
- import os
- x = 0
- s = socket.socket()
- host = socket.gethostname()
- port = 80
- s.bind(( host , port))
- s.listen(5)
- name = "file-name="
- iname = "image-name="
- while True:
- c, addr = s.accept() # Establish connection with client.
- print 'Got connection from', addr
- print "Receiving..."
- l=c.recv(1024)
- index=l.index(name)
- index=index+len(name)
- index2=l.index("HTTP")
- file_name=l[index:index2]
- print(file_name)
- f=open('upload/'+"("+str(x)+")"+file_name, 'wb')
- while l:
- l=c.recv(1024)
- f.write(l)
- f.close()
- print "Done Receiving"
- c.send('Thank you for connecting')
- c.close()
- x+=1
- print "server is shutting down"
- s.shutdown()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement