Advertisement
bennyp

Untitled

Feb 19th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. async function postPythonScript() {
  2.   const url = 'https://run.glot.io/languages/python/latest';
  3.   const body = JSON.stringify({files: [{name: "main.py", content: "print(7)"}]});
  4.   const token = "41354f0c-5b9a-45d3-b0d0-66b444f555d4"; // doesn't need to be so secret.
  5.   const method = 'POST';
  6.   const headers = new Headers({
  7.     'Authorization': token,
  8.     'Content-Type': 'application/json',
  9.   });
  10.  
  11.   try {
  12.     const response = await fetch(url, {method, headers, body});
  13.     print(data);
  14.   } catch (error) {
  15.     console.error(error);
  16.   }
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement