Minimalistic Python client for pastes.dev
Project description
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_user_agent
# set custom API endpoint (optional)
_set_api_url("https://my-api.example.com")
# set custom user agent (optional)
_set_user_agent("My project/1.0.0")
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, _set_user_agent
import asyncio
# set custom API endpoint (optional)
_set_api_url("https://my-api.example.com")
# set custom user agent (optional)
_set_user_agent("My project/1.0.0")
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.5.1.post1.tar.gz
(16.3 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
File details
Details for the file pastes-1.5.1.post1.tar.gz.
File metadata
- Download URL: pastes-1.5.1.post1.tar.gz
- Upload date:
- Size: 16.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a3cacd88254b63f8654d62f5e5fc46176d2c360a8c59f2c6e55ac3082a1df53a
|
|
| MD5 |
08d7a42e20e388512a0aa0090baf7e7d
|
|
| BLAKE2b-256 |
fd5f862013baf5e07f75d0fa19317c9d100a0bca96b683cda6853de6b428f483
|
File details
Details for the file pastes-1.5.1.post1-py3-none-any.whl.
File metadata
- Download URL: pastes-1.5.1.post1-py3-none-any.whl
- Upload date:
- Size: 16.7 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 |
1c75d9d449224df23a4ea8d379002f12962ad594b73a1b68b075729d8b7c0314
|
|
| MD5 |
2604c1d97b21d0e90eb1fb21aabf9e4e
|
|
| BLAKE2b-256 |
e42397369ccb5a64f5627b6c1939fed84ff378f87b19ebb46bc137bf610e211a
|