Minimalistic Python client for pastes.dev
Project description
Pastes
Minimalistic Python client for pastes.dev Share your code in seconds with a simple function call.
✨ Features
- 🌀 Both sync and async APIs
- ⚡ One-liner usage
- 📤 Returns instant paste URL
- 🐍 Pure Python, only requests and httpx are required
📦 Installation
pip install pastes
⚡ Usage
🔹 Sync
from pastes import paste, get_paste, _set_api_url
# set custom API endpoint (optional)
_set_api_url("https://my-api.example.com")
code = """
def fib(n):
a, b = 0, 1
while a < n:
print(a, end=' ')
a, b = b, a+b
print()
fib(1000)
"""
# create paste
url = paste(code)
print(url) # https://pastes.dev/UUHlliP7SF
# fetch paste
print(get_paste(url)) # def fib(n): ...
🔹 Async
from pastes import apaste, aget_paste, _set_api_url
import asyncio
# set custom API endpoint (optional)
_set_api_url("https://my-api.example.com")
code = """
def fib(n):
a, b = 0, 1
while a < n:
print(a, end=' ')
a, b = b, a+b
print()
fib(1000)
"""
async def main():
# create paste
url = await apaste(code)
print(url) # https://pastes.dev/UUHlliP7SF
# fetch paste
text = await aget_paste(url)
print(text) # def fib(n): ...
asyncio.run(main())
👨💻 Author
Made with ❤️ by @RimMirK
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
pastes-1.4.2.tar.gz
(16.0 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
pastes-1.4.2-py3-none-any.whl
(16.4 kB
view details)
File details
Details for the file pastes-1.4.2.tar.gz.
File metadata
- Download URL: pastes-1.4.2.tar.gz
- Upload date:
- Size: 16.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7342b1905cf4341e49d91f7bf982d5ef656e8531c4238780bd05cc4aeba9551d
|
|
| MD5 |
a1f12403f14dcd5dd8ba91f25812091b
|
|
| BLAKE2b-256 |
2b46ff299917c1c0e0ece3454e4144be0807a88f3f7a0dee78fc1fed8eec6cd9
|
File details
Details for the file pastes-1.4.2-py3-none-any.whl.
File metadata
- Download URL: pastes-1.4.2-py3-none-any.whl
- Upload date:
- Size: 16.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b00fe109bf5571d40116d490161f407f79e5e96d2fabb846e2ae17a5ce62769d
|
|
| MD5 |
46487744ad1334c03767485c43a42cdf
|
|
| BLAKE2b-256 |
59287d7fe7ee7b1aacec09a5b7e8ed00caa6e7f306647692613c2156df9523eb
|