Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/Barnard-PL-Labs/tsl-api int…
Browse files Browse the repository at this point in the history
…o main
  • Loading branch information
santolucito committed Nov 30, 2022
2 parents 17d5bc3 + 4155c70 commit 9f671e1
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 18 deletions.
29 changes: 24 additions & 5 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ const app = express();
var cors = require('cors');
app.use(cors());

app.use(require('body-parser').urlencoded({ extended: false }));

// Verify the the dot utility is available at startup
// instead of waiting for a first request.
//fs.accessSync('/usr/bin/dot', fs.constants.X_OK);
Expand All @@ -31,9 +33,22 @@ app.get('/', (req, res) => {

// [START cloudrun_system_package_handler]
// [START run_system_package_handler]
app.get('/tslsynth', (req, res) => {
app.post('/tslsynth', function(req, res){
var tsl = req.body.tsl;
var target = req.body.target;
var user = req.body.user;

console.log("User ID:")
console.log(user);

console.log("tslSpec:");
console.log(tsl);

console.log("target:")
console.log(target);

try {
const synthResult = createDiagram(req.query.tsl, req.query.target);
const synthResult = createDiagram(tsl, target);
res.setHeader('Content-Type', 'text/plain');
res.setHeader('Cache-Control', 'public, max-age=86400');
res.send(synthResult);
Expand All @@ -48,9 +63,13 @@ app.get('/tslsynth', (req, res) => {
}
});

app.get('/tslminrealizable', (req, res) => {
app.post('/tslminrealizable', (req, res) => {
console.log("User ID:")
console.log(req.body.user);

try {
const synthResult = createMinDiagram(req.query.tsl);
const synthResult = createMinDiagram(req.body.tsl);

res.setHeader('Content-Type', 'text/plain');
res.setHeader('Cache-Control', 'public, max-age=86400');
res.send(synthResult);
Expand Down Expand Up @@ -88,7 +107,7 @@ const createDiagram = (tsl, target) => {
input: tsl,
});

console.log("synthResult");
console.log("synthResult:");
console.log(String(synthResult));

return synthResult;
Expand Down
19 changes: 7 additions & 12 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,19 @@
<meta name="generator" content="Hugo 0.88.1">
<title>TSL Synth</title>
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"> </script>
<script>
function callSynth() {
tslSpec = document.getElementById("specBox").value;
tslSpec = encodeURIComponent(tslSpec.replace(/\n/g, " "));
targetLang = document.getElementById("targetLang").value;
fetch("https://graphviz-web-vvxsiayuzq-ue.a.run.app/tslsynth?tsl="+tslSpec+"&target="+targetLang)
.then(response => {
response.text().then(function(text) {
document.getElementById("codeBox").value = text;
});
})
.catch(error => console.error(error));
let tslSpec = document.getElementById("specBox").value;
let targetLang = document.getElementById("targetLang").value;
$.post("https://graphviz-web-vvxsiayuzq-ue.a.run.app/tslsynth", {tsl: tslSpec, target: targetLang, id: userID}, function(data){
document.getElementById("codeBox").value = data;
});
}
</script>

</script>

<link rel="canonical" href="https://getbootstrap.com/docs/5.1/examples/starter-template/">


<!-- Bootstrap core CSS -->
<link href="./assets/dist/css/bootstrap.min.css" rel="stylesheet">
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
},
"dependencies": {
"cors": "^2.8.5",
"express": "^4.17.1"
"express": "^4.17.1",
"body-parser": "^1.15.2"
},
"devDependencies": {
"google-auth-library": "^7.0.0",
Expand Down

0 comments on commit 9f671e1

Please sign in to comment.