A set of simple functions to upload and fetch pastes on paste.uploadgram.me
Project description
pastegram-py
A set of simple functions to upload and fetch pastes on paste.uploadgram.me.
API Documentation
Methods
upload_paste(contents: bytes, filename: str) -> UploadedPaste
:
Uploads a paste.
argument | required | default |
---|---|---|
contents | yes | |
filename | no | paste |
Returns: the UploadedPaste
fetch_paste(url: str) -> str
Fetches the paste and returns the contents as string.
argument | required | default |
---|---|---|
url | yes |
Returns: The paste's contents as string
Types
UploadedPaste
An uploaded paste
Fields
field | type | description |
---|---|---|
token | str | An unique token that can be used to delete the paste |
downloadId | str | The paste's download id |
key | bytes | The paste's decryption key as bytes |
Methods
UploadedPaste.get_url() -> str
Gets the paste's shareable url
Errors
ParseError
Raised when an error occurs while parsing. May be thrown by fetch_paste()
APIError
Raised when an error occurs while fetching/parsing an API reponse. May be thrown by upload_paste()
Examples
Upload a paste and fetch it back
from pastegram import upload_paste, fetch_paste, UploadedPaste
def main():
print('uploading paste...')
paste: UploadedPaste = upload_paste(b'hello')
print(paste.token)
print(paste.get_url())
print('re-downloading paste...')
contents: str = fetch_paste(paste.get_url())
print(contents)
if __name__ == '__main__':
main()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pastegram-1.0.0.tar.gz
(4.2 kB
view hashes)
Built Distribution
Close
Hashes for pastegram-1.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 10c14e3811e93053325af2e82cdce3bd95d70179f1da2cfb1e3c92fa4f8dd192 |
|
MD5 | 3b86eade4806a2544ffdc4594e619502 |
|
BLAKE2b-256 | a13fbefa23bdc6e640239021a1d60d9e6f889f8a12278f65b2ee692a6458c1c8 |