2019-10-21 20:07:17 +00:00
|
|
|
import pytio
|
|
|
|
import gzip
|
|
|
|
import io
|
|
|
|
|
|
|
|
tio = pytio.Tio()
|
|
|
|
|
improve, deliver, create, develop, design, operate, manage, produce, modernize, complicate, nationalize, placate, evolve, alter, amend, change or obliterate code
2021-05-31 19:14:04 +00:00
|
|
|
async def languages(http_session):
|
|
|
|
return await (await http_session.get("https://tio.run/languages.json")).json()
|
2019-10-21 20:07:17 +00:00
|
|
|
|
|
|
|
aliases = {
|
2020-05-12 16:08:03 +00:00
|
|
|
"python": "python3",
|
|
|
|
"javascript": "javascript-node"
|
2019-10-21 20:07:17 +00:00
|
|
|
}
|
|
|
|
|
improve, deliver, create, develop, design, operate, manage, produce, modernize, complicate, nationalize, placate, evolve, alter, amend, change or obliterate code
2021-05-31 19:14:04 +00:00
|
|
|
async def run(http_session, lang, code):
|
2020-04-18 12:14:31 +00:00
|
|
|
real_lang = aliases.get(lang, lang)
|
|
|
|
req = pytio.TioRequest(real_lang, code)
|
improve, deliver, create, develop, design, operate, manage, produce, modernize, complicate, nationalize, placate, evolve, alter, amend, change or obliterate code
2021-05-31 19:14:04 +00:00
|
|
|
res = await (await http_session.post("https://tio.run/cgi-bin/run/api/", data=req.as_deflated_bytes(), timeout=65)).text()
|
2021-07-17 21:09:17 +00:00
|
|
|
split = list(filter(lambda x: x != "\n" and x != "", res.split(res[:16])))
|
2019-10-21 20:07:17 +00:00
|
|
|
if len(split) == 1:
|
2020-04-18 12:14:31 +00:00
|
|
|
return False, real_lang, split[0], None
|
2019-10-21 20:07:17 +00:00
|
|
|
else:
|
2020-05-12 16:08:03 +00:00
|
|
|
return True, real_lang, split[0], split[1]
|