同步操作将从 xzhangcqjtu/OnlinePythonTutor 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
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.
2018年03月04日 - moved the C/C++ backend into this directory; it was
previously in a separate github repo since it was so big:
https://github.com/pgbovine/opt-cpp-backend
... but I decided it's easier if everything is together in one repo
---
Setup instructions:
This has been tested in the following version of Node.js for Linux:
node-v6.9.5-linux-x64.tar.xz
... which comes in this repo. Untar it in your home directory:
untar it and add this to .bashrc to find it:
export PATH=$HOME/node-v6.9.5-linux-x64/bin:"$PATH"
symlink node to /usr/bin/node so that as soon as the machine restarts,
the environment knows where to find node before your own .bashrc runs:
e.g.,:
sudo ln -s /home/pgbovine/node-v6.9.5-linux-x64/bin/node /usr/bin/
Let this node.js process bind to privileged ports < 1024 as non-root:
sudo setcap 'cap_net_bind_service=+ep' /home/pgbovine/node-v6.9.5-linux-x64/bin/node
https://gist.github.com/firstdoit/6389682
[If you install Node with your OS's package manager, then there's no
guarantee that it will work!]
First install global dependencies:
npm install -g jshint
npm install -g forever
To install cokapi's node dependencies, run 'make deps'
(this 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.)
---
Before you can actually run the backends, you'll also need to install
and configure Docker to run the individual backends in backends/
See Makefile and Dockerfile in each respective directory for details!
---
I also recommend to clear out all 'created' (but not actively running)
docker containers every ~10 minutes by putting an entry in your crontab:
*/10 * * * * docker rm -f $(docker ps -a -f status=created)
Check out crontabs.txt for details
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,
});
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。