diff --git a/contrib/proxy/README b/contrib/proxy/README index af61aa65..c0d5d657 100644 --- a/contrib/proxy/README +++ b/contrib/proxy/README @@ -16,7 +16,7 @@ set this to 1 5) run make in directory with this file. The proxy.py should be generated and some files with .txt extension. -6) run proxy.py +6) run python3 proxy.py 7) run ELinks and set protocol.http.proxy = localhost:8000 diff --git a/contrib/proxy/gen.c b/contrib/proxy/gen.c index 6e7807ab..dbd74c09 100644 --- a/contrib/proxy/gen.c +++ b/contrib/proxy/gen.c @@ -17,23 +17,23 @@ struct { } tab[100000]; /* should be enough */ unsigned char header[] = -"#!/usr/bin/env python\n" -"import BaseHTTPServer\n\n"; +"#!/usr/bin/env python3\n" +"import http.server\n\n"; unsigned char footer[] = -"class Serwer(BaseHTTPServer.BaseHTTPRequestHandler):\n" -"\tdef do_GET(self):\n" -"\t\tglobal slownik\n" -"\t\tof = open(slownik[self.path])\n" -"\t\tprint (self.path)\n" -"\t\tself.wfile.write(of.read())\n" -"\t\tof.close()\n\n" -"\tdef do_POST(self):\n" -"\t\tself.do_GET()\n\n" -"def run(server_class = BaseHTTPServer.HTTPServer, handler_class = Serwer):\n" -"\tserver_address = ('', 8000)\n" -"\thttpd = server_class(server_address, handler_class)\n" -"\thttpd.serve_forever()\n\n" +"class Serwer(http.server.BaseHTTPRequestHandler):\n" +" def do_GET(self):\n" +" global slownik\n" +" of = open(slownik[self.path], 'rb')\n" +" print(self.path)\n" +" self.wfile.write(of.read())\n" +" of.close()\n\n" +" def do_POST(self):\n" +" self.do_GET()\n\n" +"def run(server_class = http.server.HTTPServer, handler_class = Serwer):\n" +" server_address = ('', 8000)\n" +" httpd = server_class(server_address, handler_class)\n" +" httpd.serve_forever()\n\n" "run()\n"; static unsigned char * @@ -121,10 +121,10 @@ dicts(FILE *f) fprintf(f, "slownik = {\n"); for (i = 0; i < counter - 1; i++) { - fprintf(f, "\t'http://%s%s' : '%d.http',\n", tab[i].host, tab[i].string, i); + fprintf(f, " 'http://%s%s' : '%d.http',\n", tab[i].host, tab[i].string, i); } for (; i < counter; i++) { - fprintf(f, "\t'http://%s%s' : '%d.http'\n", tab[i].host, tab[i].string, i); + fprintf(f, " 'http://%s%s' : '%d.http'\n", tab[i].host, tab[i].string, i); } fprintf(f, "}\n\n"); }