Share your code using gist consoles


Have you ever wanted to share some code with someone, and make it really easy for them to run it and see what it does? Perhaps an answer to a Stack Overflow question, or just something you want to link from an IRC chat where you’re explaining something? GitHub has gists, an excellent feature for sharing version-tracked code snippets, but sometimes just sharing the code isn’t enough – you want people to see what happens when they run it.

With PythonAnywhere, you can create a link that will run a gist from GitHub in a browser-based console. It’s really easy to set up!

First, create your gist on GitHub:

Next, go to our gist console setup page:

Enter the URL of your gist, and hit the “Fetch gist” button.

Select the file inside the gist that you want to run, and which Python interpreter (Python 2 or 3, regular Python or IPython) you want to use.

Immediately, you’ll see a URL displayed at the bottom of the page. You can copy or paste the link, or go directly to the page to see what it looks like:

When people follow the link, they’ll be taken to a page with the gist running in a console.

One thing to be aware of; if you’re logged in to a PythonAnywhere account when you follow a link to a gist console, it will want to run the gist code inside your account. Obviously this could be dangerous if someone wrote a gist that did terrible things and put a link somewhere for you to click, so if you’re logged in to PythonAnywhere, we display a warning page before the gist is run:

What would you like to use gist consoles for? What do you think might make them even more useful?

comments powered by Disqus