项目作者: HIT-matsumotolab

项目描述 :
Amadeus Core (Go Implementation)
高级语言: Go
项目地址: git://github.com/HIT-matsumotolab/Amadeus-Core.git
创建时间: 2017-01-14T19:06:19Z
项目社区:https://github.com/HIT-matsumotolab/Amadeus-Core

开源协议:

下载


Amadeus Core (Go implementation)

Amadeus is Online Compiler on Hiroshima Institute of Technology.
This repository is an experimental Amadeus Go implementation.


Setup

See https://linuxcontainers.org/ja/lxd/getting-started-cli/

  1. sudo apt install lxd
  2. newgrp lxd
  3. sudo lxd init
  4. lxc launch images:debian/jessie admin
  5. lxc exec admin -- /bin/bash
  6. apt update
  7. apt install clang gcc build-essential

Config

Edit config/config.toml.

  1. [development]
  2. bind = "127.0.0.1"
  3. port = 8080
  4. lxcname = "admin" # Container Name

Launch Amadeus Core

On 127.0.0.1:8080

  1. ./server

or

  1. go run server.go

API

POST /api/compiler/

  • Code : Source Code
  • Language : Compile Language
    • Current Support : clang
  • Stdin : Stdin Text
  • Stdout : Stdout
  • Stderr : Stderr

Example

  1. curl -i -H 'Content-Type: application/json' -d @sample/simple_stdout.json localhost:8080/api/compiler/
  2. HTTP/1.1 200 OK
  3. Content-Type: application/json; charset=utf-8
  4. X-Powered-By: go-json-rest
  5. Date: Sat, 14 Jan 2017 19:04:13 GMT
  6. Content-Length: 204
  7. {
  8. "Code": "#include \u003cstdio.h\u003e\nint main() {\n printf(\"HELLO\\n\");\n return 0;\n}\n",
  9. "Language": "clang",
  10. "Stdin": "",
  11. "Stdout": "HELLO\n",
  12. "Stderr": "0"
  13. }
  1. curl -i -H 'Content-Type: application/json' -d @sample/simple_stdout.json localhost:8080/api/compiler/
  2. HTTP/1.1 200 OK
  3. Content-Type: application/json; charset=utf-8
  4. X-Powered-By: go-json-rest
  5. Date: Sat, 14 Jan 2017 19:03:23 GMT
  6. Content-Length: 235
  7. {
  8. "Code": "#include \u003cstdio.h\u003e\nint main(){\nint i = 0;\nscanf(\"%d\", \u0026i);\nprintf(\"%d\\n\", i*2);\nreturn 0;\n}\n",
  9. "Language": "clang",
  10. "Stdin": "10\n",
  11. "Stdout": "20\n",
  12. "Stderr": "0"
  13. }

Test

  1. go test -v ./