From 8eba5d71effe4850d0d8db347b849fd8d8f59cb6 Mon Sep 17 00:00:00 2001 From: Aaron Gutierrez Date: Wed, 16 Jan 2019 21:54:17 -0800 Subject: [PATCH] Initial commit --- index.html | 15 +++++++++++++++ proxy.cgi | 39 +++++++++++++++++++++++++++++++++++++++ template.html | 9 +++++++++ 3 files changed, 63 insertions(+) create mode 100644 index.html create mode 100755 proxy.cgi create mode 100644 template.html diff --git a/index.html b/index.html new file mode 100644 index 0000000..3287b31 --- /dev/null +++ b/index.html @@ -0,0 +1,15 @@ + + + + + TextProxy + + +

TextProxy

+
+ + + +
+ + diff --git a/proxy.cgi b/proxy.cgi new file mode 100755 index 0000000..f76e099 --- /dev/null +++ b/proxy.cgi @@ -0,0 +1,39 @@ +#!/usr/bin/env python3 + +import cgi +import cgitb +import subprocess + +cgitb.enable() + +def fetch_site(url): + data = subprocess.check_output(['w3m', '-dump', url]) + return output.decode() + +def format_output(url, data): + with open('template.html', 'r') as f: + template = f.read() + + return template.format(url, data) + +def print_headers(): + print('Content-Type: text/html; charset=utf8') + print() + +def main(): + form = cgi.FieldStorage() + + if 'u' not in form or len(form['u']) == 0: + print('Status: 400 Bad Request') + print() + print('Missing required field') + print() + return + + url = form['u'] + data = fetch_site(url) + + print(format_output(url, data)) + +if __name__ == '__main__': + main() diff --git a/template.html b/template.html new file mode 100644 index 0000000..b3d8a80 --- /dev/null +++ b/template.html @@ -0,0 +1,9 @@ + + + + {} - TextProxy + + +
{}
+ +