Giter Site home page Giter Site logo

kushagra-goyal-14 / codebox Goto Github PK

View Code? Open in Web Editor NEW
4.0 1.0 0.0 30 KB

A scalable Node.js-powered platform for executing code with ease, scaled with Docker, Redis & Rabbit-MQ

Home Page: https://code-box-gamma.vercel.app/

Dockerfile 4.37% JavaScript 95.63%
backend code-editor compiler docker express high-level-design javascript nodejs rabbitmq redis scaled

codebox's Introduction

CodeBox

API is still under early stages of development, so feel free to contribute in the project.

Introducing the new CodeBox API

An API which executes codes

Info

This version is not hosted, you can access the deployed version here - "https://github.com/kushagra-goyal-14/CodeBox-API"

Requirements !!

Docker and docker-compose should be present on the machine.

Step 1 :

Clone the repo

Step 2 : building the images and start the container.

docker compose up

Execute Code and fetch output

POST /

This endpoint allows you to execute your script and fetch output results.

Inputs required for API call -

Parameter Description
"src" Should contain the script that needs to be executed
"stdin" In case the script requires any kind of input for execution, leave empty if no input required
"lang" Language that the script is written in for example: java, cpp, etc. (Check language as a payload down below in next question)

What are the languages that are supported for execution?

All the Languages are listed below .

Languages Language as a payload
C++ cpp
Java java
Python python3
C c
GoLang go
JS javascript

On Postman : (recommended)

Sending a json post request to http://localhost:3300/api/v1/submit

It is a c++ script to print Hello World.

{
  "src": "\n\n#include<bits/stdc++.h>\n\nusing namespace std ;\n\nint main()\n{  cout << \"Hello World \"<< endl ;}",
  "stdin": "48\n95",
  "lang": "cpp"
}

The output is a JSON object comprising only one parameter that is the output.

{
  "message": "Successfully ran it",
  "data": "http://localhost:3300/api/v1/results/Test59b64ddfdd6978a4fef4",
  "err": {},
  "success": true
}

GET /

Make a GET request on http://localhost:3300/api/v1/results/Test59b64ddfdd6978a4fef4

the output will be

{
  "message": "Successfully got it",
  "data": "{\"output\":\"Hello World \\n\",\"status\":\"Success\",\"stderr\":\"\",\"submission_id\":\"Test59b64ddfdd6978a4fef4\"}",
  "err": {},
  "success": true
}


Different types of status:


"status": "Invalid Request"

If the field in post request is empty then it will show invalid request


"status":"Queued"

If the request is in waiting stage i.e. in queue.


"status":"Processing"

Script is running


"status":"Runtime Error"

Most probably timeout happened


"status":"Failed"

Causes due to compilation error or runtime error.


"status":"Successful"

Worked Successfully !!



PORT - 3300

This port is exposed by docker-compose.

This project is not deployed as it requires a full instance due to various microservices, but a version will be deployed that is not scaled like this version but will be usefull for running all the codes.

codebox's People

Contributors

kushagra-goyal-14 avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.