aboutsummaryrefslogtreecommitdiffstats
path: root/youtube
diff options
context:
space:
mode:
Diffstat (limited to 'youtube')
-rw-r--r--youtube/search.py10
-rw-r--r--youtube/youtube.py3
2 files changed, 9 insertions, 4 deletions
diff --git a/youtube/search.py b/youtube/search.py
index 406dc82..8bb3aff 100644
--- a/youtube/search.py
+++ b/youtube/search.py
@@ -9,9 +9,6 @@ from youtube import common, proto
with open("yt_search_results_template.html", "r") as file:
yt_search_results_template = file.read()
-
-with open("yt_search_template.html", "r") as file:
- yt_search_template = file.read()
page_button_template = Template('''<a class="page-button" href="$href">$page</a>''')
current_page_button_template = Template('''<div class="page-button">$page</div>''')
@@ -83,7 +80,12 @@ did_you_mean = Template('''
def get_search_page(query_string, parameters=()):
qs_query = urllib.parse.parse_qs(query_string)
if len(qs_query) == 0:
- return yt_search_template
+ return common.yt_basic_template.substitute(
+ page_title = "Search",
+ header = common.get_header(),
+ style = '',
+ page = '',
+ )
query = qs_query["query"][0]
page = qs_query.get("page", "1")[0]
autocorrect = int(qs_query.get("autocorrect", "1")[0])
diff --git a/youtube/youtube.py b/youtube/youtube.py
index 93b947f..03956b6 100644
--- a/youtube/youtube.py
+++ b/youtube/youtube.py
@@ -15,6 +15,9 @@ def youtube(env, start_response):
mime_type = mimetypes.guess_type(path)[0] or 'application/octet-stream'
start_response('200 OK', (('Content-type',mime_type),) )
return f.read()
+ elif path.lstrip('/') == "":
+ start_response('200 OK', (('Content-type','text/html'),) )
+ return search.get_search_page(query_string).encode()
elif path == "/comments":
start_response('200 OK', (('Content-type','text/html'),) )