Github – way to embed github code into an iframe

githubiframe

The question may seem confusing so let me clarify.

Github lets you see the source code of a files in a repo. I want to include them in iframes but am unsure how and suspect someone has already done this before.

In my case I want to add https://github.com/ileathan/hubot-mubot/blob/master/src/mubot.coffee to an iframe so that from my website people can see the code as it evolves.

Best Solution

A GitHub page itself wouldn't be put directly in a iframe (because of the X-Frame-Options: deny HTTP header).

That leaves you with the GitHub API for contents

GET /repos/:owner/:repo/contents/:path

Like: https://api.github.com/repos/ileathan/hubot-mubot/contents/src/mubot.coffee.

You should be able to put that content in a iframe (as in this answer)