Skip to content

Instantly share code, notes, and snippets.

@mudassaralichouhan
Created November 10, 2025 09:11
Show Gist options
  • Select an option

  • Save mudassaralichouhan/ef56b34c022061f1c4dfab6001fca61d to your computer and use it in GitHub Desktop.

Select an option

Save mudassaralichouhan/ef56b34c022061f1c4dfab6001fca61d to your computer and use it in GitHub Desktop.
Upload data on remote machine

for download

server

python3 -m http.server 8000 --directory /var/www/html/staging

client

curl -O http://178.128.42.36:8000/database/database.sqlite

for upload:

server

from http.server import BaseHTTPRequestHandler, HTTPServer

class SimpleUploadServer(BaseHTTPRequestHandler):
    def do_POST(self):
        length = int(self.headers['Content-Length'])
        data = self.rfile.read(length)
        with open("received_file", "wb") as f:
            f.write(data)
        self.send_response(200)
        self.end_headers()
        self.wfile.write(b"File received successfully.")

if __name__ == "__main__":
    server = HTTPServer(("0.0.0.0", 8000), SimpleUploadServer)
    print("Listening on port 8000...")
    server.serve_forever()
touch upload_server.py && python upload_server.py

client

curl -X POST -H "Content-Type: application/octet-stream" --data-binary "@C:\path\to\video.mp4" http://178.128.42.36:8000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment