Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add convert endpoint
  • Loading branch information
Priyanjoli-Mukherjee committed Jun 26, 2025
commit 0142739995ff6f33cae6eb51df127450b50bf3e7
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
ENERGY=20 GeV
JDBC_DATABASE_URL=jdbc:postgresql://localhost:5432/portfolio
2 changes: 1 addition & 1 deletion Procfile
Original file line number Diff line number Diff line change
@@ -1 +1 @@
web: java -jar target/java-getting-started-1.0.0-SNAPSHOT.jar
web: java -jar target/portfolio-backend-1.0.0-SNAPSHOT.jar
4 changes: 2 additions & 2 deletions app.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "Start on Heroku: Java",
"description": "A barebones Java app, which can easily be deployed to Heroku.",
"name": "Priya Mukherjee Portfolio",
"description": "Portfolio Backend for Priya Mukherjee",
"addons": ["heroku-postgresql"]
}
9 changes: 7 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<name>java-getting-started</name>
<name>portfolio-backend</name>

<parent>
<groupId>org.springframework.boot</groupId>
Expand All @@ -13,7 +13,7 @@
</parent>

<groupId>com.heroku</groupId>
<artifactId>java-getting-started</artifactId>
<artifactId>portfolio-backend</artifactId>
<version>1.0.0-SNAPSHOT</version>

<properties>
Expand Down Expand Up @@ -41,6 +41,11 @@
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
</dependency>
<dependency>
<groupId>org.jscience</groupId>
<artifactId>jscience</artifactId>
<version>4.3.1</version>
</dependency>
</dependencies>

<build>
Expand Down
13 changes: 13 additions & 0 deletions src/main/java/com/heroku/java/GettingStartedApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
import java.util.ArrayList;
import java.util.Map;

import org.jscience.physics.amount.Amount;
import org.jscience.physics.model.RelativisticModel;
import javax.measure.unit.SI;

@SpringBootApplication
@Controller
public class GettingStartedApplication {
Expand Down Expand Up @@ -48,6 +52,15 @@ String database(Map<String, Object> model) {
}
}

@GetMapping("/convert")
String convert(Map<String, Object> model) {
RelativisticModel.select();
var energy = Amount.valueOf("12 GeV");

model.put("result", "E=mc^2: " + energy + " = " + energy.to(SI.KILOGRAM));
return "convert";
}

public static void main(String[] args) {
SpringApplication.run(GettingStartedApplication.class, args);
}
Expand Down
8 changes: 8 additions & 0 deletions src/main/resources/templates/convert.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" th:replace="~{fragments/layout :: layout (~{::body},'hello')}">
<body>
<div class="container">
<p th:text="${result}"/>
</div>
</body>
</html>