Last active
October 14, 2022 17:43
-
-
Save JoyGhoshs/7de33a4b92fba1ce49e09189c32800f2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
import json | |
import argparse | |
parser = argparse.ArgumentParser() | |
def compile_code(lang, code): | |
api = "https://paiza.io:443/api/projects.json" | |
headers = {"Sec-Ch-Ua": "\"Not;A=Brand\";v=\"99\", \"Chromium\";v=\"106\"", "Accept": "application/json", "Content-Type": "application/json; charset=UTF-8", "X-Xsrf-Token": "\"mXfKR7uqZ6RaWov51f88QoL2VPVOYcLgKp1h7A0XVZPnw493XPMnyF/7oDVEr0MHny2sYcOtSq36l/Rl/L5Azg==\"", "Sec-Ch-Ua-Mobile": "?0", "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/106.0.5249.62 Safari/537.36", "Sec-Ch-Ua-Platform": "\"Windows\"", "Origin": "https://paiza.io", "Sec-Fetch-Site": "same-origin", "Sec-Fetch-Mode": "cors", "Sec-Fetch-Dest": "empty", "Referer": "https://paiza.io/en/projects/new", "Accept-Encoding": "gzip, deflate", "Accept-Language": "en-US,en;q=0.9", "Connection": "close"} | |
json = {"project": {"language": lang, "network": True, "output_type": None, "share": "private", "source_files": [{"body": code, "filename": "Main.php", "position": 0}]}, "run": True, "save": True} | |
data = requests.post(api, headers=headers, json=json) | |
return data.json()['stdout'] | |
parser.add_argument("--lang", help="Language to use", default="python3") | |
parser.add_argument("--code", help="Code to run", default="print('hello')") | |
args = parser.parse_args() | |
hlang = args.lang | |
code = args.code | |
print(compile_code(hlang, code)) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment