diff options
Diffstat (limited to 'flakes/paste/paste/paste.py')
-rw-r--r-- | flakes/paste/paste/paste.py | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/flakes/paste/paste/paste.py b/flakes/paste/paste/paste.py index 86666b8..3172de5 100644 --- a/flakes/paste/paste/paste.py +++ b/flakes/paste/paste/paste.py | |||
@@ -10,9 +10,32 @@ import mimetypes | |||
10 | 10 | ||
11 | magic = magic.Magic(mime=True) | 11 | magic = magic.Magic(mime=True) |
12 | 12 | ||
13 | mit_license = """ | ||
14 | Copyright (c) 2022 Immae | ||
15 | |||
16 | Permission is hereby granted, free of charge, to any person obtaining a copy | ||
17 | of this software and associated documentation files (the "Software"), to deal | ||
18 | in the Software without restriction, including without limitation the rights | ||
19 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
20 | copies of the Software, and to permit persons to whom the Software is | ||
21 | furnished to do so, subject to the following conditions: | ||
22 | |||
23 | The above copyright notice and this permission notice shall be included in all | ||
24 | copies or substantial portions of the Software. | ||
25 | |||
26 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
27 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
28 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
29 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
30 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
31 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
32 | SOFTWARE. | ||
33 | """ | ||
34 | |||
13 | config = { | 35 | config = { |
14 | "directory": os.environ["PASTE_DIRECTORY"], | 36 | "directory": os.environ["PASTE_DIRECTORY"], |
15 | "self_paste_id": "abcd123", | 37 | "self_paste_id": "abcd123", |
38 | "license_paste_id": "license", | ||
16 | "max_content_length": 16 * 1000 * 1000 | 39 | "max_content_length": 16 * 1000 * 1000 |
17 | } | 40 | } |
18 | 41 | ||
@@ -33,6 +56,8 @@ def read_paste(paste_id): | |||
33 | if mime.startswith("text/x-script."): | 56 | if mime.startswith("text/x-script."): |
34 | mime="text/plain" | 57 | mime="text/plain" |
35 | return (content, mime) | 58 | return (content, mime) |
59 | elif paste_id == config["license_paste_id"]: | ||
60 | return (mit_license, "text/plain") | ||
36 | else: | 61 | else: |
37 | abort(404) | 62 | abort(404) |
38 | 63 | ||
@@ -69,9 +94,11 @@ $ curl -X POST --data-binary @{self} {host} | |||
69 | -> GET {paste}/download | 94 | -> GET {paste}/download |
70 | force download of file | 95 | force download of file |
71 | </pre> | 96 | </pre> |
72 | <a href="{paste}/py">Get the source</a> | 97 | <a href="{paste}/py">Get the source</a><br /> |
98 | Software licensed under the terms of the <a href="{host}/license">MIT license</a> | ||
73 | '''.format(host=url_for('post_paste', _external=True, _scheme="https"), | 99 | '''.format(host=url_for('post_paste', _external=True, _scheme="https"), |
74 | paste=url_for('get_paste', _external=True, _scheme="https", paste_id=config["self_paste_id"]), | 100 | paste=url_for('get_paste', _external=True, _scheme="https", paste_id=config["self_paste_id"]), |
101 | license=url_for('get_paste', _external=True, _scheme="https", paste_id=config["license_paste_id"]), | ||
75 | self=os.path.basename(__file__) | 102 | self=os.path.basename(__file__) |
76 | ), mimetype="text/html") | 103 | ), mimetype="text/html") |
77 | 104 | ||