Skip to content

defcronyke/rust-playground-api

Repository files navigation

Rust Playground API

sponsor the project github-pipeline pipeline status


v0.1.2 - 2021 by Jeremy Carter <[email protected]>

GitLab: https://gitlab.com/defcronyke/rust-playground-api
GitHub: https://github.com/defcronyke/rust-playground-api


Run some Rust code online. Get the program's output, as well as assembly and WebAssembly, as a JSON response.

Example:
https://tinyurl.com/rust-playground-api?id=1ea016619193533f9ac6cd1d8ae22d58
https://tinyurl.com/rust-playground-api-run?id=1ea016619193533f9ac6cd1d8ae22d58
https://tinyurl.com/rust-playground-api-wasm?id=1ea016619193533f9ac6cd1d8ae22d58
https://tinyurl.com/rust-playground-api-asm?id=1ea016619193533f9ac6cd1d8ae22d58


Automated builds from the master branch

Release Binary

Debug Binary

NOTE: After downloading and extracting from the GitHub mirror, you need to run the following commands because GitHub Actions isn't preserving the correct permissions for the files:

cd rust-playground-api && chmod 755 *

(Optional) Clone the source code with git

git clone https://github.com/defcronyke/rust-playground-api.git && \
cd rust-playground-api

Run the program

  • Automated build version:

    ./rust-playground-api
  • Git source version:

    ./serve.sh

Usage

  1. Make a GitHub secret or public Gist, with your desired Rust program code in it:
    https://gist.github.com

  2. Get the Gist's ID from its URL, for example the id value as below:
    https://gist.github.com/{username}/{id}

  3. Run the Rust code by using the id in your GET request, for example:
    http://localhost:8080/?id=1ea016619193533f9ac6cd1d8ae22d58


API routes available

Use your desired "GitHub Gist ID" for the id GET query parameter in the example requests below. The Rust code in that Gist will be used for the query.


Build and run the Docker container

  • Build the dependencies image:

    ./deps.sh
  • Build the production image:

    ./prod.sh
  • Run the Docker container:

    ./start.sh
  • Stop the Docker container when finished:

    ./stop.sh