Giter Club home page Giter Club logo

code-sharing-platform's Introduction

Code Sharing Platform

API /api

Get code snippet by UUID

Returns JSON:

{
  "code": "CODE SNIPPET",
  "date": "THE DATE IT WAS POSTED",
  "time": 0, // Time left to view the snippet (0 - unlimited)
  "views": 0 // Number of views left for the snippet (0 - unlimited)
}

Get 10 latest unrestricted code snippets

Returns JSON array:

[
  {
    "code": "CODE SNIPPET 10",
    "date": "THE DATE IT WAS POSTED",
    "time": 0, // Time left to view the snippet (0 - unlimited) (guarenteed to be 0)
    "views": 0 // Number of views left for the snippet (0 - unlimited) (guarenteed to be 0)
  },
  ...
  {
    "code": "CODE SNIPPET 1",
    "date": "THE DATE IT WAS POSTED",
    "time": 0, // Time left to view the snippet (0 - unlimited) (guarenteed to be 0)
    "views": 0 // Number of views left for the snippet (0 - unlimited) (guarenteed to be 0)
  }
]

Post a code snippet

Consumes JSON:

{
  "code": "YOUR CODE SNIPPET", // Must not be null
  "time": 0, // Time left to view the snippet (0 - unlimited)
  "views": 0 // Number of views left for the snippet (0 - unlimited)
}

Returns JSON:

{
  "id": "YOUR CODE SNIPPET UUID"
}

Web Interface /

Get code snippet by UUID

Get 10 latest unrestricted code snippets

Get the html page for updating the code snippet

Examples

Example 1

Request POST /api/code/new with the following body:

{
    "code": "class Code { ...",
    "time": 0,
    "views": 0
}

Response: { "id" : "7dc53df5-703e-49b3-8670-b1c468f47f1f" }.

Request POST /api/code/new with the following body:

{
    "code": "public static void ...",
    "time": 0,
    "views": 0
}

Response: { "id" : "e6780274-c41c-4ab4-bde6-b32c18b4c489" }.

Request POST /api/code/new with the following body:

{
    "code": "Secret code",
    "time": 5000,
    "views": 5
}
Response: { "id" : "2187c46e-03ba-4b3a-828b-963466ea348c" }.

Example 2

Request: GET /api/code/2187c46e-03ba-4b3a-828b-963466ea348c

Response:

{
    "code": "Secret code",
    "date": "2020/05/05 12:01:45",
    "time": 4995,
    "views": 4
}

Another request GET /api/code/2187c46e-03ba-4b3a-828b-963466ea348c

Response:

{
    "code": "Secret code",
    "date": "2020/05/05 12:01:45",
    "time": 4991,
    "views": 3
}

Example 3

Request: GET /code/2187c46e-03ba-4b3a-828b-963466ea348c

Response:

image

Example 4

Request: GET /api/code/latest

Response:

[
    {
        "code": "public static void ...",
        "date": "2020/05/05 12:00:43",
        "time": 0,
        "views": 0
    },
    {
        "code": "class Code { ...",
        "date": "2020/05/05 11:59:12",
        "time": 0,
        "views": 0
    }
]

Example 5

Request: GET /code/latest

Response:

image

Example 6

Request: GET /code/new

Response:

image

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.