haskell / play-haskell

Haskell Playground
130 stars 9 forks source link

Running external code snippets via the playground #26

Closed reubenharry closed 1 year ago

reubenharry commented 1 year ago

Apologies if this is a silly question, but I'm interested in being able to run Haskell code snippets on my own pages, and I'm wondering if I can use this project. For example, on a page like https://haskell-docs.netlify.app/packages/megaparsec/ it would be great if I could add a "run code" button, that would either link to the playground with the code pasted in, or even directly run it on the site.

Do you have any thoughts on how I might achieve that?

tomsmeding commented 1 year ago

Have you looked at the API section in the README? On your webpage you should be able to send a POST request to the playground instance directly, e.g. via XHR. This way your server doesn't have to do anything, and spam control tracks your users' IP address instead of your server's, which makes that work too.

Does that work for you or do you need something different?

reubenharry commented 1 year ago

Sounds great, somehow I missed that!