Return blank page for searching when visiting just localhost/youtube.com
This commit is contained in:
parent
dcc3183411
commit
1dc2cb0ab6
@ -10,9 +10,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])
|
||||
|
@ -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'),) )
|
||||
|
@ -1,79 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Search</title>
|
||||
<link title="Youtube local" href="/youtube.com/opensearch.xml" rel="search" type="application/opensearchdescription+xml">
|
||||
<style type="text/css">
|
||||
|
||||
body{
|
||||
margin:0;
|
||||
padding: 0;
|
||||
|
||||
color:#222;
|
||||
//background-color:#888888;
|
||||
background-color:#cccccc;
|
||||
|
||||
min-height:100vh;
|
||||
|
||||
display:grid;
|
||||
grid-template-columns: 3fr 1fr;
|
||||
grid-template-rows: 50px 1fr;
|
||||
}
|
||||
h3{
|
||||
margin:0;
|
||||
}
|
||||
#header{
|
||||
grid-column: 1 / span 3;
|
||||
grid-row: 1;
|
||||
|
||||
grid-template-columns: 3fr 1fr;
|
||||
|
||||
}
|
||||
#header-left{
|
||||
display:grid;
|
||||
|
||||
grid-template-columns: 1fr 800px;
|
||||
|
||||
}
|
||||
|
||||
|
||||
#left{
|
||||
grid-column: 1;
|
||||
grid-row: 1;
|
||||
|
||||
#right{
|
||||
|
||||
|
||||
grid-column: 2;
|
||||
grid-row: 1;
|
||||
|
||||
}
|
||||
|
||||
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="header">
|
||||
<div id="header-left">
|
||||
<form id="search-form" action="/youtube.com/search">
|
||||
<input type="text" name="query" id="search-box">
|
||||
<input type="submit" value="Search" id="search-button">
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="left">
|
||||
</div>
|
||||
|
||||
|
||||
<div id="right">
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
Loading…
x
Reference in New Issue
Block a user