Server development on Spring Boot and some basics in Web-programming such as HTML, CSS, and JS. Code sharing platform is a web service that can help you share a piece of code with other programmers. The main feature of this service is that it is supposed to be accessible only locally, not via the Internet.
- Two types of interfaces: API and web interface
- The API interface returns data as
JSON - The web interface uses
HTML,JS, andCSS - H2 database
- Hibernate
- Spring MVC
- Project Lombok
- Template engine Thymeleaf
To run the service from CMD:
- Open CMD and go to .\Code_Sharing_Platform
- Launch gradle (the wrapper is already included in the project package): .\Code_Sharing_Platform gradlew run
- Server.port is 8889
- In order to test the service please use Postman REST Client (you may download it from the official: https://www.postman.com/downloads/)
POST /api/code/newreturns a UUID of the snippet;
Request body: JSON object with a field code and two other fields:
time field contains the time (in seconds) during which the snippet is accessible;
views field contains a number of views allowed for this snippet (excluding the current one);
Note: 0 and negative values correspond to the absence of the restriction.
-
GET /code/newreturns HTML that contains:- input field that contains the time restriction;
- input field that contains the views restriction;
- textarea where you can paste a code snippet;
- button "Submit";
-
GET /api/code/latestreturns a JSON array with 10 most recently uploaded code snippets sorted from the newest to the oldest. It does not return any restricted snippets. -
GET /code/latestreturns HTML that contains 10 most recently uploaded code snippets. It does not return any restricted snippets. -
GET /api/code/UUIDreturns JSON with the appropriate UUID uploaded code snippet and restrictions applied to the code piece. It is not accessible if one of the restrictions is triggered. And returns404 Not Foundin this case and all the cases when no snippet with such a UUID was found. -
GET /code/UUIDreturns HTML that contains info about:- the time restriction;
- the views restriction;
- the code snippet;
It is not accessible if one of the restrictions is triggered. And returns 404 Not Found in this case and all the cases when no snippet with such a UUID was found.
Example 1
POST /api/code/newrequest
Request body:
{
"code": "class Code { ...",
"time": 0,
"views": 0
}
Response body:
{ "id" : "82540e2a-a1e6-442f-be93-60ed6aa45e00" }
POST /api/code/newrequest
Request body:
{
"code": "public static void ...",
"time": 0,
"views": 0
}
Response body:
{ "id" : "f76299dd-424b-4fcd-8650-831249b809da" }
POST /api/code/newrequest
Request body:
{
"code": "Secret code",
"time": 5000,
"views": 5
}
Response body:
{ "id" : "f53434a6-80b7-45ca-ac9a-5e094e9e42b5" }
Example 2
GET /api/code/f53434a6-80b7-45ca-ac9a-5e094e9e42b5request
Response body:
{
"code": "Secret code",
"date": "2022-12-29T08:48:31.571328200Z",
"time": 4971,
"views": 4
}
GET /api/code/f53434a6-80b7-45ca-ac9a-5e094e9e42b5request
Response body:
{
"code": "Secret code",
"date": "2022-12-29T08:48:31.571328200Z",
"time": 4920,
"views": 3
}
Example 3
GET /code/f53434a6-80b7-45ca-ac9a-5e094e9e42b5request
Response:
Example 4
GET /api/code/latestrequest
Response body:
[
{
"code": "public static void ...",
"date": "2022-12-29T08:48:14.518376Z",
"time": 0,
"views": 0
},
{
"code": "class Code { ...",
"date": "2022-12-29T08:47:09.661470800Z",
"time": 0,
"views": 0
}
]
Example 5
GET /code/latestrequest
Response:
Example 6
GET /code/newrequest
Response:
To find more about this project, please visit https://hyperskill.org/projects/130.


