diff options
author | Joris | 2024-05-20 09:40:11 +0200 |
---|---|---|
committer | Joris | 2024-05-20 09:40:11 +0200 |
commit | 436ddf6f23242eb709b591cd5e9cbf1553f8d390 (patch) | |
tree | dfed58b5e553f131fd3009f03f095ca40efc5949 /src/templates.py | |
parent | 6baa0419d3b5eb63c70be446226a321f900e433d (diff) |
Allow to upload file and download from given link
Diffstat (limited to 'src/templates.py')
-rw-r--r-- | src/templates.py | 97 |
1 files changed, 97 insertions, 0 deletions
diff --git a/src/templates.py b/src/templates.py new file mode 100644 index 0000000..1308fc0 --- /dev/null +++ b/src/templates.py @@ -0,0 +1,97 @@ +import html + +page: str = ''' + <!doctype html> + <html lang="fr"> + <meta charset="utf-8"> + <meta name="viewport" content="width=device-width"> + + <title>Files</title> + <link rel="stylesheet" href="/main.css"> + <script src="/main.js"></script> + + <a href="/"> + <h1>Files</h1> + </a> +''' + +index: str = f''' + {page} + + <form> + <label> + File + <input type="file" name="file" required> + </label> + + <label> + Expiration + <select name="expiration"> + <option value="1">1 day</option> + <option value="2">2 days</option> + <option value="3">3 days</option> + <option value="4">4 days</option> + <option value="5">5 days</option> + <option value="6">6 days</option> + <option value="7" selected>7 days</option> + <option value="8">8 days</option> + <option value="9">9 days</option> + <option value="10">10 days</option> + <option value="11">11 days</option> + <option value="12">12 days</option> + <option value="13">13 days</option> + <option value="14">14 days</option> + <option value="15">15 days</option> + <option value="16">16 days</option> + <option value="17">17 days</option> + <option value="18">18 days</option> + <option value="19">19 days</option> + <option value="20">20 days</option> + <option value="21">21 days</option> + <option value="22">22 days</option> + <option value="23">23 days</option> + <option value="24">24 days</option> + <option value="25">25 days</option> + <option value="26">26 days</option> + <option value="27">27 days</option> + <option value="28">28 days</option> + <option value="29">29 days</option> + <option value="30">30 days</option> + <option value="31">31 days</option> + </select> + </label> + + <label> + Key + <input type="password" name="key" required> + </label> + + <div class="g-Loading"> + <div class="g-Spinner"></div> + Uploading… + </div> + + <div class="g-Error"> + </div> + + <input type="submit" value="Upload"> + </form> +''' + +def download(href: str, filename: str, expires: str) -> str: + return f''' + {page} + + <div> + <a class="g-Link" href="{html.escape(href)}">{html.escape(filename)}</a> + <div> + Expires: {html.escape(expires)} + </div> + </div> + ''' + +not_found: str = f''' + {page} + + Sorry, the file you are looking for can not be found. It may have already expired. +''' |