Skip to main content

Minimalistic Python client for pastes.dev

Project description

pasters pasters

PyPI Python License StandWithUkraine

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


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.5rc1.tar.gz (16.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pastes-1.5rc1-py3-none-any.whl (16.6 kB view details)

Uploaded Python 3

File details

Details for the file pastes-1.5rc1.tar.gz.

File metadata

  • Download URL: pastes-1.5rc1.tar.gz
  • Upload date:
  • Size: 16.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for pastes-1.5rc1.tar.gz
Algorithm Hash digest
SHA256 643a1029ebefb0682e89dd590ed337801ece8da8cb649075cece5e6f10ece2e5
MD5 c4dbca5604d075e0fefd6b131f837af9
BLAKE2b-256 ce334b5536beeb1fb315cc611f08771785bacbeed41ac823af370b0c90eda7a0

See more details on using hashes here.

File details

Details for the file pastes-1.5rc1-py3-none-any.whl.

File metadata

  • Download URL: pastes-1.5rc1-py3-none-any.whl
  • Upload date:
  • Size: 16.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for pastes-1.5rc1-py3-none-any.whl
Algorithm Hash digest
SHA256 74e75eabbd50f67b48c75860d65b28c97bb18d086b142478f3d56eb27d8e22b2
MD5 93340ab2f80268b1e9d23384d1d68b21
BLAKE2b-256 9f02999daa2b9a22a111a0080f3ff7ce9621b5378faf23c46bc19bc7ff67afab

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page