From 6f2d29a2c76f3ee3f5c38e04e65f6824ff7bbc12 Mon Sep 17 00:00:00 2001 From: Kartikay Shandil Date: Fri, 26 May 2023 00:20:35 +0530 Subject: [PATCH 1/6] Improve Readme --- README.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 1c1c0803..ee98a96a 100644 --- a/README.md +++ b/README.md @@ -71,11 +71,14 @@ Content-Type: application/json In order to submit a solution, follow these steps. - Fork the **nano-demo-calculator-app** repository ([How to fork a repository github](https://docs.github.com/en/get-started/quickstart/fork-a-repo)) + - Deselect the "Copy the main branch only" to copy other language demos as well - Clone the forked repository ([How to clone a repository github](https://docs.github.com/en/repositories/creating-and-managing-repositories/cloning-a-repository)) +- Change the branch according to the language of your choice (This demo is available in (language-> branch) "kotlin"-> main, "node" -> "node", "python" -> "python", "cpp" -> "cpp" ) ([How to change branches git ](https://www.freecodecamp.org/news/git-switch-branch/)) +- Enable workflows in your github fork (Under the actions tab -> Select "I understand my workflows, go ahead and enable them" to enable the test workflow) - Use your favourite editor to make changes - Create a commit after testing it locally ([How to commit git](https://github.com/git-guides/git-commit)) -- Push the commit to the remote (github repo) ([How to push git](https://docs.github.com/en/get-started/using-git/pushing-commits-to-a-remote-repository)) -- If all your changes work well, you will see a green tick on the actions section on your repo ([How to see last run action](https://docs.github.com/en/actions/monitoring-and-troubleshooting-workflows/viewing-workflow-run-history)) +- Push the commit to the remote **to the same branch** (github repo) ([How to push git](https://docs.github.com/en/get-started/using-git/pushing-commits-to-a-remote-repository)) +- If all your changes work well, you will see a green tick on the actions section on your repo under the selected branch ([How to see last run action](https://docs.github.com/en/actions/monitoring-and-troubleshooting-workflows/viewing-workflow-run-history)) - If it's a cross mark, the logs will tell you what you did wrong. - Fix the issue, and repeat steps 4+ to resubmit - Congratulations, you have successfully solved the dummy problem and are ready for the actual hackathon. From 01dbb316aad78c8522ea99593916f0bc7abf7406 Mon Sep 17 00:00:00 2001 From: Kartikay Shandil Date: Fri, 26 May 2023 11:45:13 +0530 Subject: [PATCH 2/6] Improve Readme --- .gitignore | 1 + README.md | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index e4d227ce..b7d015fb 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,4 @@ out/ .classpath .factorypath *newman/ +.vscode/ diff --git a/README.md b/README.md index ee98a96a..4ff05f7e 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ At Sahaj, tech consultants operate at the intersection between engineering and art. Simply put, they are artisans who take on complex engineering problems in the software industry across a wide spectrum of domains. Their work is deeply rooted in first principles thinking - asking fundamental questions to dissect and understand a problem which eventually leads to one-of-a-kind solutions, each as distinct as a fingerprint. -Through NaN(O), a hackathon driven by Sahaj across multiple colleges in India, they want to instill a culture of applying first principles thinking to a problem statement. +Through NaN(O), a coding event driven by Sahaj across multiple colleges in India, they want to instil a culture of applying first principles thinking to a problem statement. ------ @@ -81,7 +81,7 @@ In order to submit a solution, follow these steps. - If all your changes work well, you will see a green tick on the actions section on your repo under the selected branch ([How to see last run action](https://docs.github.com/en/actions/monitoring-and-troubleshooting-workflows/viewing-workflow-run-history)) - If it's a cross mark, the logs will tell you what you did wrong. - Fix the issue, and repeat steps 4+ to resubmit -- Congratulations, you have successfully solved the dummy problem and are ready for the actual hackathon. +- Congratulations, you have successfully solved the dummy problem and are ready for the actual event. ###### Hint From 18ca4816823c76965fa9cc8d590060e53aad62bd Mon Sep 17 00:00:00 2001 From: Karun Japhet Date: Tue, 1 Aug 2023 12:41:06 +0530 Subject: [PATCH 3/6] Fix logo --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 4ff05f7e..38673c9f 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -

- +

+Logo

## What is NaN(O) From 7a071a7784e0b28880e58d3dc5e7869f243f5fd5 Mon Sep 17 00:00:00 2001 From: Joshna-josh <109268806+Joshna-josh@users.noreply.github.com> Date: Fri, 15 Sep 2023 18:41:04 +0530 Subject: [PATCH 4/6] update server.py --- server.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 server.py diff --git a/server.py b/server.py new file mode 100644 index 00000000..28058860 --- /dev/null +++ b/server.py @@ -0,0 +1,27 @@ +from flask import Flask,request,jsonify + +app = Flask(__name__) + + +@app.route("/calculator/greeting", methods=['GET']) +def greeting(): + return 'Hello world!' + +@app.route("/calculator/add", methods=['POST']) +def add(): + data = request.json + first = data['first'] + second = data['second'] + result = first + second + return jsonify({'result': result}) + +@app.route("/calculator/subtract", methods=['POST']) +def subtract(): + data = request.json + first = data['first'] + second = data['second'] + result = first - second + return jsonify({'result': result}) + +if _name_ == '__main__': + app.run(port=8080,host='0.0.0.0') From 1c9374ad32c5dbfd45a3911058c72963dae2ead2 Mon Sep 17 00:00:00 2001 From: Joshna-josh Date: Sat, 16 Sep 2023 08:52:21 +0530 Subject: [PATCH 5/6] update --- server.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server.py b/server.py index 28058860..af1c9c19 100644 --- a/server.py +++ b/server.py @@ -5,7 +5,7 @@ @app.route("/calculator/greeting", methods=['GET']) def greeting(): - return 'Hello world!' + return 'Hello worldd!' @app.route("/calculator/add", methods=['POST']) def add(): @@ -22,6 +22,6 @@ def subtract(): second = data['second'] result = first - second return jsonify({'result': result}) - + if _name_ == '__main__': app.run(port=8080,host='0.0.0.0') From 47ecef63a6eaba07436bd340491f804b03ecc6ed Mon Sep 17 00:00:00 2001 From: Joshna-josh Date: Sat, 16 Sep 2023 08:53:34 +0530 Subject: [PATCH 6/6] commit --- bin/main/application.yml | 7 ++++++ bin/main/com/nano/Application.kt | 7 ++++++ bin/main/com/nano/MathController.kt | 28 ++++++++++++++++++++++ bin/main/com/nano/Numbers.kt | 8 +++++++ bin/main/logback.xml | 15 ++++++++++++ bin/test/com/nano/DemoCalculatorAppTest.kt | 19 +++++++++++++++ server.py | 2 +- 7 files changed, 85 insertions(+), 1 deletion(-) create mode 100644 bin/main/application.yml create mode 100644 bin/main/com/nano/Application.kt create mode 100644 bin/main/com/nano/MathController.kt create mode 100644 bin/main/com/nano/Numbers.kt create mode 100644 bin/main/logback.xml create mode 100644 bin/test/com/nano/DemoCalculatorAppTest.kt diff --git a/bin/main/application.yml b/bin/main/application.yml new file mode 100644 index 00000000..400863bc --- /dev/null +++ b/bin/main/application.yml @@ -0,0 +1,7 @@ +micronaut: + application: + name: nanoDemoCalculatorApp +netty: + default: + allocator: + max-order: 3 diff --git a/bin/main/com/nano/Application.kt b/bin/main/com/nano/Application.kt new file mode 100644 index 00000000..628f9abb --- /dev/null +++ b/bin/main/com/nano/Application.kt @@ -0,0 +1,7 @@ +package com.nano + +import io.micronaut.runtime.Micronaut.run +fun main(args: Array) { + run(*args) +} + diff --git a/bin/main/com/nano/MathController.kt b/bin/main/com/nano/MathController.kt new file mode 100644 index 00000000..1f444340 --- /dev/null +++ b/bin/main/com/nano/MathController.kt @@ -0,0 +1,28 @@ +package com.nano + +import io.micronaut.http.HttpResponse +import io.micronaut.http.MediaType +import io.micronaut.http.annotation.Controller +import io.micronaut.http.annotation.Get +import io.micronaut.http.annotation.Post +import io.micronaut.validation.Validated + +@Controller("/calculator") +@Validated +class MathController { + + @Get("/greeting") + fun greeting(): HttpResponse { + return HttpResponse.ok("") + } + + @Post("/add", produces = [MediaType.APPLICATION_JSON]) + fun add(): HttpResponse { + return HttpResponse.ok("") + } + + @Post("/subtract", produces = [MediaType.APPLICATION_JSON]) + fun subtract(): HttpResponse { + return HttpResponse.ok("") + } +} diff --git a/bin/main/com/nano/Numbers.kt b/bin/main/com/nano/Numbers.kt new file mode 100644 index 00000000..a2673c93 --- /dev/null +++ b/bin/main/com/nano/Numbers.kt @@ -0,0 +1,8 @@ +package com.nano + +import javax.validation.constraints.NotNull + +data class Numbers( + @field:NotNull val first: Int, + @field:NotNull val second: Int +) diff --git a/bin/main/logback.xml b/bin/main/logback.xml new file mode 100644 index 00000000..6010eb52 --- /dev/null +++ b/bin/main/logback.xml @@ -0,0 +1,15 @@ + + + + true + + + %cyan(%d{HH:mm:ss.SSS}) %gray([%thread]) %highlight(%-5level) %magenta(%logger{36}) - %msg%n + + + + + + + diff --git a/bin/test/com/nano/DemoCalculatorAppTest.kt b/bin/test/com/nano/DemoCalculatorAppTest.kt new file mode 100644 index 00000000..f0a72dfc --- /dev/null +++ b/bin/test/com/nano/DemoCalculatorAppTest.kt @@ -0,0 +1,19 @@ +package com.nano +import io.micronaut.runtime.EmbeddedApplication +import io.micronaut.test.extensions.junit5.annotation.MicronautTest +import org.junit.jupiter.api.Assertions +import org.junit.jupiter.api.Test +import jakarta.inject.Inject + +@MicronautTest +class DemoCalculatorAppTest { + + @Inject + lateinit var application: EmbeddedApplication<*> + + @Test + fun testItWorks() { + Assertions.assertTrue(application.isRunning) + } + +} diff --git a/server.py b/server.py index af1c9c19..5bcd250d 100644 --- a/server.py +++ b/server.py @@ -5,7 +5,7 @@ @app.route("/calculator/greeting", methods=['GET']) def greeting(): - return 'Hello worldd!' + return 'Hello world!' @app.route("/calculator/add", methods=['POST']) def add():