I was wondering if there is an API interface to get the GCODE viewer to show the file that is being printed or if a javascript code is available to integrate in an app



this do? http://docs.octoprint.org/en/master/api/job.html#retrieve-information-about-the-current-job


I just used my octo-client software from npmjs.com to quickly query the currently-running job's filename using NodeJS. I assume that you have Node and npm installed:

cd sites
mkdir octo-getjob && cd octo-getjob
touch octo-getjob
chmod a+x octo-getjob
npm init    # When asked for the entry point, indicate "octo-getjob"
npm install --save octo-client
nano node_modules/octo-client/config.js # Edit as necessary with your API key
nano octo-getjob

octo-getjob contents:

#!/usr/bin/env node

var OctoPrint = require('octo-client');

# Displays "pizero-case-parts-nocutout.gcode"


I am looking for an API that can actually show the graphic of the GCODE just like in ../#gcode view so that I can embed that in my web page



I could think of three approaches.

  1. Copy the existing code to create just the content you want and make your own API endpoint
  2. Create a script which does a curl of the Gcode tab page and then remove the HTML that you're not interested in.
  3. Create a proxy which does this


Could you give an example of the approaches, that will help


Any of the above would be a fair amount of work, to be honest. I attempted to determine a quick-and-dirty method of using awk at the command line to pare down the page but it's not something that would be easy.

Perhaps others would like to take on the challenge.