Skip to content

Instantly share code, notes, and snippets.

@nikhilkumarsingh
Created March 3, 2019 16:31
Show Gist options
  • Save nikhilkumarsingh/b17f8d00bf58514e5874a8b5d9f0d192 to your computer and use it in GitHub Desktop.
Save nikhilkumarsingh/b17f8d00bf58514e5874a8b5d9f0d192 to your computer and use it in GitHub Desktop.
GeeksforGeeks free, unrestricted online compiler api
import requests
gfg_compiler_api_endpoint = "https://ide.geeksforgeeks.org/main.php"
languages = ['C', 'Cpp', 'Cpp14', 'Java', 'Python', 'Python3', 'Scala', 'Php', 'Perl', 'Csharp']
def gfg_compile(lang, code, _input=None, save=False):
data = {
'lang': lang,
'code': code,
'input': _input,
'save': save
}
r = requests.post(gfg_compiler_api_endpoint, data=data)
return r.json()
if __name__ == "__main__":
lang = 'Cpp14'
code = """
#include <iostream>
using namespace std;
int main() {
int a, b;
cin >> a >> b;
cout << (a+b);
return 0;
}
"""
_input = "1 5"
print(gfg_compile(lang, code, _input))
@Dhirenkm
Copy link

How to get output of execution?

@PATHAKABHISHEK
Copy link

This is sort of scraping and it is not an official api and I think it is not good of you have large base of users who want to submit code through this api

@RAHUL-B-PILLAI
Copy link

I guess this method does not work any more

@pouriaafshari
Copy link

Thank you for sharing this great API. I really want to suck your ... never mind :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment