Pistonpy
An unofficial wrapper for Engineer Man's Piston API
Install / Use
/learn @AalbatrossGuy/PistonpyREADME
Key Features
- Simple modern and efficient Pythonic API using the
requestslib. - Supports application integration and CLI usage.
Requirements
Python 3.8+
Installing
To install the library, run the following commands:
# Linux/MacOS
python3 -m pip install -U pistonpy
# Windows
py -3 -m pip install -U pistonpy
Usage
from pistonpy import PistonApp
# Initialize the client.
piston = PistonApp()
my_code = "print('This code ran from app.py itself!')"
output = piston.run(language="python", version="3.10.0", code=my_code)
print(output)
This gives the output:
{'language': 'python', 'version': '3.10.0', 'run': {'stdout': 'This code ran from app.py itself!\n', 'stderr': '', 'code': 0, 'signal': None, 'output': 'This code ran from app.py itself!\n'}}
run_file = piston.run(language="python", files=['test.py']) # version is optional. files even if it maybe only one must be given as lists.
print(run_file)
This gives the same output,
{'language': 'python', 'version': '3.10.0', 'run': {'stdout': 'The code ran from test.py\n', 'stderr': '', 'code': 0, 'signal': None, 'output': 'The code ran from test.py\n'}}
# You cannot provide both code and files in a single PistonAPP().run() instance.
# For running multiple files (For now it ONLY supports multiple python files)
multiple_files = piston.run(language="python", version="3.10.0", files=['test.py', 'test_two.py'])
print(multiple_files)
Sadly, the output for multiple files are provided all-together. This will be fixed in the upcoming updates. The above statement will output to:
{'language': 'python', 'version': '3.10.0', 'run': {'stdout': 'The code ran from test.py\nthis is test 2\n', 'stderr': '', 'code': 0, 'signal': None, 'output': 'The code ran from test.py\nthis is test 2\n'}}
print(piston.languages) # Prints the available languages along with their version.
print(piston.aliases) # Prints the available languages along with their alias/aliases.
print(piston.raw) # Prints the raw data without any formatting done.
License
This project is distributed under the MIT license.
Piston
For visiting Piston's github repository, click here.
Related Skills
node-connect
336.9kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
83.0kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
336.9kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
commit-push-pr
83.0kCommit, push, and open a PR
