Skip to content

GET and POST Request Routes (Data Format) #1

Description

@sebastian-nunez

GET and POST Request Routes

GET

GET request to /problems/1 should return the following JSON data:

{
  "id": "1",
  "title": "Two Sum",
  "difficulty": "Easy",
  "objectives": [
    "Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target.",
    "You may assume that each input would have exactly one solution, and you may not use the same element twice.",
    "You can return the answer in any order."
  ],
  "examples": [
    {
      "input": "nums = [2,7,11,15], target = 9",
      "output": "[0,1]",
      "explanation": "Because nums[0] + nums[1] == 9, we return [0, 1]."
    },
    {
      "input": "nums = [3,2,4], target = 6",
      "output": "[1,2]"
    },
    {
      "input": "nums = [3,3], target = 6",
      "output": "[0,1]"
    }
  ],
  "starterCode": "def twoSum(nums: List[int], target: int) -> List[int]:\n\t# Code here...\n\tpass"
}

POST

This how a post request (in Javascript) looks like for /problems/1/play:

fetch('/problems/1/play', {
    method: 'POST',
    headers: {
      'Accept': 'application/json',
      'Content-Type': 'application/json'
    },
    body: {
        'language': 'python',
        'script': 'def twoSum(nums: List[int], target: int) -> List[int]:\n\t# Code here...\n\tpass'
    }
  });

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions