diff options
author | Joris | 2024-06-02 14:38:13 +0200 |
---|---|---|
committer | Joris | 2024-06-02 14:38:22 +0200 |
commit | 1019ea1ed341e3a7769c046aa0be5764789360b6 (patch) | |
tree | 1a0d8a4f00cff252d661c42fc23ed4c19795da6f /src/templates.py | |
parent | e8da9790dc6d55cd2e8883322cdf9a7bf5b4f5b7 (diff) |
Migrate to Rust and Hyper
With sanic, downloading a file locally is around ten times slower than
with Rust and hyper.
Maybe `pypy` could have helped, but I didn’t succeed to set it up
quickly with the dependencies.
Diffstat (limited to 'src/templates.py')
-rw-r--r-- | src/templates.py | 105 |
1 files changed, 0 insertions, 105 deletions
diff --git a/src/templates.py b/src/templates.py deleted file mode 100644 index 8125f69..0000000 --- a/src/templates.py +++ /dev/null @@ -1,105 +0,0 @@ -import html -import datetime - -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="/static/main.css"> - <script src="/static/main.js"></script> - - <a href="/"> - <h1>Files</h1> - </a> -''' - -pub 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 file_page(file_id: str, filename: str, expires: str) -> str: - href = f'{file_id}/download' - expires_in = datetime.datetime.strptime(expires, '%Y-%m-%d %H:%M:%S') - datetime.datetime.now() - - print() - print(href) - print() - - return f''' - {page} - - <div> - <a class="g-Link" href="{html.escape(href)}">{html.escape(filename)}</a> - <div> - Expires in {expires_in} - </div> - </div> - ''' - -not_found: str = f''' - {page} - - Oops, not found! -''' |