Skip to main content

Minimalistic Python client for pastes.dev

Project description

Pastes

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 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


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.1.tar.gz (15.6 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.4.1-py3-none-any.whl (16.2 kB view details)

Uploaded Python 3

File details

Details for the file pastes-1.4.1.tar.gz.

File metadata

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

File hashes

Hashes for pastes-1.4.1.tar.gz
Algorithm Hash digest
SHA256 7e22334abad782f10eddeda0c29c73924233a71f058caa39194ca0deb6df0716
MD5 b712ce112f8db658757bd8f443bb7109
BLAKE2b-256 086dba6f41bb0b959e3c442f72cea58bed240a70b3593712ef993f764a873876

See more details on using hashes here.

File details

Details for the file pastes-1.4.1-py3-none-any.whl.

File metadata

  • Download URL: pastes-1.4.1-py3-none-any.whl
  • Upload date:
  • Size: 16.2 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.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 599b08952a1d7a6fbe37c1273d0a9b886facd6adab395034669c92e4416400b1
MD5 0bde0e6b6abd9b5fed0bb3c550ef0fec
BLAKE2b-256 6375af3a1e2183a5577c2a1d4e73b847a4c705d8c2d2ea8fda25196047e20d2d

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