mirror of
https://github.com/rkd77/elinks.git
synced 2024-12-04 14:46:47 -05:00
[python3] proxy.py ported to python3. Refs #38
This commit is contained in:
parent
4fb19bd1fd
commit
0eaf9526bb
@ -16,7 +16,7 @@ set this to 1
|
|||||||
5) run make in directory with this file. The proxy.py should be generated
|
5) run make in directory with this file. The proxy.py should be generated
|
||||||
and some files with .txt extension.
|
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
|
7) run ELinks and set protocol.http.proxy = localhost:8000
|
||||||
|
|
||||||
|
@ -17,23 +17,23 @@ struct {
|
|||||||
} tab[100000]; /* should be enough */
|
} tab[100000]; /* should be enough */
|
||||||
|
|
||||||
unsigned char header[] =
|
unsigned char header[] =
|
||||||
"#!/usr/bin/env python\n"
|
"#!/usr/bin/env python3\n"
|
||||||
"import BaseHTTPServer\n\n";
|
"import http.server\n\n";
|
||||||
|
|
||||||
unsigned char footer[] =
|
unsigned char footer[] =
|
||||||
"class Serwer(BaseHTTPServer.BaseHTTPRequestHandler):\n"
|
"class Serwer(http.server.BaseHTTPRequestHandler):\n"
|
||||||
"\tdef do_GET(self):\n"
|
" def do_GET(self):\n"
|
||||||
"\t\tglobal slownik\n"
|
" global slownik\n"
|
||||||
"\t\tof = open(slownik[self.path])\n"
|
" of = open(slownik[self.path], 'rb')\n"
|
||||||
"\t\tprint (self.path)\n"
|
" print(self.path)\n"
|
||||||
"\t\tself.wfile.write(of.read())\n"
|
" self.wfile.write(of.read())\n"
|
||||||
"\t\tof.close()\n\n"
|
" of.close()\n\n"
|
||||||
"\tdef do_POST(self):\n"
|
" def do_POST(self):\n"
|
||||||
"\t\tself.do_GET()\n\n"
|
" self.do_GET()\n\n"
|
||||||
"def run(server_class = BaseHTTPServer.HTTPServer, handler_class = Serwer):\n"
|
"def run(server_class = http.server.HTTPServer, handler_class = Serwer):\n"
|
||||||
"\tserver_address = ('', 8000)\n"
|
" server_address = ('', 8000)\n"
|
||||||
"\thttpd = server_class(server_address, handler_class)\n"
|
" httpd = server_class(server_address, handler_class)\n"
|
||||||
"\thttpd.serve_forever()\n\n"
|
" httpd.serve_forever()\n\n"
|
||||||
"run()\n";
|
"run()\n";
|
||||||
|
|
||||||
static unsigned char *
|
static unsigned char *
|
||||||
@ -121,10 +121,10 @@ dicts(FILE *f)
|
|||||||
|
|
||||||
fprintf(f, "slownik = {\n");
|
fprintf(f, "slownik = {\n");
|
||||||
for (i = 0; i < counter - 1; i++) {
|
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++) {
|
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");
|
fprintf(f, "}\n\n");
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user