Using create.withcode.uk to embed python code in an external website

Create.withcode.uk lets you write, run, debug and share python code in your browser. It’s designed for use in the classroom as a free online resource for teachers to help students grow in confidence, independence and resilience when writing python code.

Create.withcode.uk uses a subset of the python language which runs in your web browser. This allows you to safely run python code on almost any web-enabled device.

This is guide is for developers who have an educational tool which contains / generates python code, who want to allow users to view / edit / run that code with all the features that create.withcode.uk supports (e.g. microbit / pygame zero / gpiozero / tkinter emulation).

If you’re just looking to embed code that you’ve written in create.withcode.uk you don’t need this facility: just save your code (or Ctrl + S) and press the share button (or Alt + Shift + S) and you’ll find a link to easily link to or embed your code in your website or blog. If you use wordpress, this plugin is designed to simplify embedding python code: https://wordpress.org/plugins/create-with-code/

Embed python code in an external website with create.withcode.uk

API

This service is currently provided for free for all for educational use.

If you use this service, the URL and IP address of the computer posting python code is logged to track usage.

Usage may have to be limited if this service is abused. Please get in touch if you have any questions.

Please note

All you need to do is post the python code to https://create.withcode.uk via HTTP with the following parameters:

Parameter: py_files:

The code you want to display or run

This can be the contents of one python code e.g.

for i in range(10,0,-1):
print(i)
print("Blast off")

or it can be a JSON collection of multiple files e.g.

{
"program.py":"with open('readme.txt') as f: \n\t print(f.read())",
"readme.txt":"You can read from and write to files with create.withcode.uk"
}

Parameter: mode:

The way you want the code to be displayed.

Values:

normal: (default) load the code in a normal window with full toolbar and ads

embed: load the code in an editor window ideal for embedding in another site (no ads, {+} button pops out into a new window)

run: displays the result of the code running rather than the code itself

Try it:

URL: https://create.withcode.uk

HTTP method: post

Result:

live.withcode.uk: Call for teachers to test new features

Well done to everyone who’s survived the first two weeks of remote learning: hats off to students who’ve got motivated to complete work at home; to teachers who’ve kept on top of remote learning whilst managing family commitments and to parents who’ve stepped up to motivate and support students learning at home. What an unusual Easter school holiday this is!

Two weeks ago, I launched the first ever live.withcode.uk python remote learning live coding session on YouTube. My audio was far too quiet (or not quiet enough for some of my students!) but last week saw the first ever competition teaming up with Mr Tait from All Saints.

live.withcode.uk: weekly free python remote learning resources

The idea is for each video to link to a choice of 4 free online remote learning activities to help students grow in confidence and experience with python programming. Thanks to everyone who has fed back about how to make the resources easier to access: we now have a new website where you can find all the links on once place for each episode: live.withcode.uk

Each video links to a choice of online remote learning resources

The next stage is to set up a scoreboard so students can compete against each other and teachers can monitor their progress as they complete the activities.

For that, I would really like some help from computing teachers who are willing to try out the new features and / or feedback how to improve the weekly content. All the resources will remain free and available but I need some volunteers to help set up competitions.

This week’s prizes are all go to students at my school for the debugging competition but I’ve secured some funding to open it up to other schools.

If you’re willing to help (or know someone who might be), please get them to sign up here: bit.ly/livewithcode

Thank you!

Coming soon: live.withcode.uk

I’ve been chatting to students, parents and other teachers about the best way to support them with remote learning during the Cornavirus school closures.

I’m hoping to set up weekly live coding python video tutorials where you can watch a quick 10 minute lesson then work through some free interactive teaching and learning resources.

This is a difficult time for all of us but it can also be a great opportunity to learn some new skills. If this sort of resource would be helpful, please reply with suggestions on what you’d most like covered and watch this space!

All the best to everyone who’s stuck at home. Thank you to everyone who’s still at work treating people who are ill and keeping us all safe and fed.

Watch this space…