YOUTUBE_URL_RE="(https:\/\/)?(www\.)?youtu(\.be|be\.com)\/watch\?v=([\w\-_]+)"
-echo "HTTP/1.1 200 OK"
-echo "Content-type: text/html"
-echo "
+PAGE="
<!DOCTYPE html>
<html>
+<meta name='viewport' content='width=device-width'>
<head>
<title>YT Download</title>
<style>
body {
- border: ridge 5px;
- max-width: max-content;
- }
- .container {
- background-color: PowderBlue;
- padding: 7px;
+ background-color: #7fa99b;
}
form {
- display: grid;
- grid-gap: 5px;
- grid-template-columns: 1fr 4fr;
+ width: min(400px, 100%);
+ }
+ fieldset {
+ background-color: #f1d18a;
+ display: flex;
+ flex-direction: column;
+ row-gap: 5px;
}
- #format {
- justify-self: end;
- width: 50%;
+ label {
+ column-gap: 5px;
+ display: flex;
+ }
+ input {
+ width: 100%;
}
</style>
</head>
<body>
- <div class='container'>
- <form action='/download'>
- <label for='url'>URL:</label>
- <input type='text' id='url' name='url' pattern='${YOUTUBE_URL_RE}'
- required />
+ <form action='/download'>
+ <fieldset>
+ <label>
+ URL:
+ <input type='text' id='url' name='url' pattern='${YOUTUBE_URL_RE}' required />
+ </label>
- <label for='format'>Format:</label>
- <input list='formats' id='format' name='format'>
+ <label>
+ Format:
+ <input list='formats' id='format' name='format'>
+ </label>
<datalist id='formats'>
<option value='video' />
<option value='audio' />
</datalist>
- <input type='submit'>
- </form>
- </div>
+ <button type='submit'>Download</button>
+ </fieldset>
+ </form>
</body>
</html>"
+
+echo "HTTP/1.1 200 OK"
+echo "Content-type: text/html"
+echo "${PAGE}" | sed 's/^[ \t]*//g'