Here's a simple implementation of an HTTPS file server in Python3 using the http.server module and the ssl module to handle the HTTPS connection:

python

import http.server
import ssl

allowed_ips = []

class SingleDownloadHandler(http.server.SimpleHTTPRequestHandler):
    def do_GET(self):
        if self.client_address[0] not in allowed_ips:
            self.send_error(403)
            return
        if self.headers.get("Range"):
            self.send_error(400)
            return
        allowed_ips.remove(self.client_address[0])
        return http.server.SimpleHTTPRequestHandler.do_GET(self)

with socketserver.TCPServer(("", 443), SingleDownloadHandler) as httpd:
    httpd.socket = ssl.wrap_socket(httpd.socket, keyfile="server.key", certfile="server.crt", server_side=True)
    allowed_ips.append(httpd.socket.getsockname()[0])
    httpd.serve_forever()
This code creates a SingleDownloadHandler class that inherits from http.server.SimpleHTTPRequestHandler and overrides the do_GET method to check if the client's IP address is in the allowed_ips list. If it is not, the server sends a 403 Forbidden error. If the client's IP address is in the allowed_ips list, the code checks if the client is trying to download a range of the file (indicated by the presence of a "Range" header in the request). If so, the server sends a 400 Bad Request error, since partial downloads are not supported. Otherwise, the code removes the client's IP address from the allowed_ips list so that it can only download the file once, and calls the parent class's do_GET method to serve the file.

Finally, the code creates a TCPServer instance on port 443 (the default port for HTTPS), sets the socket attribute to a wrapped version of the server's socket created using an SSL certificate and key, adds the server's IP address to the allowed_ips list, and starts serving requests with serve_forever().
spam fails_task lang_mismatch pii not_appropriate hate_speech sexual_content quality toxicity humor helpfulness creativity violence