Python wordpress plugin: easily embed and run python code in your website

Create.withcode.uk python wordpress plugin
Create.withcode.uk python wordpress plugin

Create.withcode.uk is designed to allow anyone to write, run, debug and share python code that runs in your browser. It’s designed primarily for use in schools to allow teachers to quickly share code with students that they can adapt, debug and use.

Here’s an example python program that asks you for your name then says hello. Press Ctrl + Enter (or click on the green plus at the bottom of the code screen) to run the code.

When you save some python code on create.withcode.uk (press Ctrl+S or click on the share button) you get an option to copy and paste some HTML code that can be embedded into any website. e.g:

<iframe frameborder="0" width="100%" height="400px" src="https://create.withcode.uk/embed/7A"><a target="_blank" href="https://create.withcode.uk/python/7A">create.withcode.uk</a></iframe>

To make it even easier to embed your python projects into your blog or website, I’ve shared a plugin for wordpress that lets you quickly add python code using a wordpress shortcode.

This makes sharing your python projects much simpler:

  1. Write your code on create.withcode.uk

    You don’t need an account – just type in your python code into the browser & test it with either Ctrl + Enter to run the whole project or Ctrl + .  to run it one line at a time

  2. Save your code

    Press Ctrl + S  or click on the share button. This make your code available to anyone with the link.

    Share your code

    The URL will be something like https://create.withcode.uk/python/ra

    Note the letters and numbers at the end of the URL ( ra  in the above example)

    Find the ID

  3. Add your code to any post or page in your wordpress blog using a shortcode:

    Use a shortcode that contains the letters and numbers from the previous step:

    Add a shortcode
    This will display the python source code in your blog page or post. People viewing your website will be able to view, run and debug your code.

  4. If you want your code to run by default rather than show the source code:

    Adapt the shortcode to change the mode to “run”:

    Shortcode to run

Wordpress python plugin
Python wordpress plugin

Click here to download the wordpress plugin or to find out more.

Like create.withcode.uk, the wordpress plugin is free and open source.

 

One thought on “Python wordpress plugin: easily embed and run python code in your website

Leave a Reply