This directory provides only backends that run on the server for
*non-Python* languages. Look in ../v5-unity/ for the Python Tutor
frontend code and the Python execution backend.
---
Release notes:
2015年01月24日 - This is an experimental version of OPT that adds support
for multiple target languages under one unified app. It relies on
Node.js for the server and docker for sandboxing.
---
Instructions:
To install node dependencies, run 'make deps'
(also depends on jshint and forever being globally-installed)
To start up the backend server, run 'make'
Note that this is really really really hard-coded for my own server
setup, so it will likely be hard for you to reproduce that setup.
You will also need to install and configure Docker to run the individual
backends in backends/ -- see Makefile and Dockerfile in each respective
directory.
Once you start up the cokapi.js Node.js server, you can ping it with
HTTP/HTTPS endpoints such as:
/exec_java
/exec_java_jsonp
to run various language backends, passing arguments in via GET
parameters. Each set of endpoints comes in a pair that returns either
regular JSON data (e.g., /exec_java) or JSONP (e.g., /exec_java_jsonp)
for cross-domain AJAX.
How does the OPT web frontend call this backend? Look at variables such
as langSettingToJsonpEndpoint in ../v5-unity/js/opt-frontend-common.ts
to see how the frontend calls the backends via JSONP using jQuery code
such as:
// the REAL call uses JSONP
// http://learn.jquery.com/ajax/working-with-jsonp/
$.ajax({
url: jsonp_endpoint,
// The name of the callback parameter, as specified by the YQL service
jsonp: "callback",
dataType: "jsonp",
data: {user_script : codeToExec,
options_json: JSON.stringify(backendOptionsObj)},
success: callbackWrapper,
});
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。