Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
real
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Paolo Guagliardo
real
Commits
3311b143
Commit
3311b143
authored
4 months ago
by
Paolo Guagliardo
Browse files
Options
Downloads
Patches
Plain Diff
Trying to get CORS to work (WIP)
parent
2a8dd0e8
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
index.html
+19
-0
19 additions, 0 deletions
index.html
index.js
+52
-0
52 additions, 0 deletions
index.js
src/main/java/uk/ac/ed/pguaglia/real/runtime/WebApp.java
+5
-2
5 additions, 2 deletions
src/main/java/uk/ac/ed/pguaglia/real/runtime/WebApp.java
with
76 additions
and
2 deletions
index.html
0 → 100644
+
19
−
0
View file @
3311b143
<!DOCTYPE html>
<html
lang=
"en"
>
<head>
<title>
REAL
</title>
<meta
charset=
"UTF-8"
/>
</head>
<body>
<label
for=
"message"
>
Query
</label>
<textarea
id=
"message"
name=
"message"
rows=
"5"
cols=
"33"
></textarea>
<script
src=
"index.js"
></script>
</body>
</html>
This diff is collapsed.
Click to expand it.
index.js
0 → 100644
+
52
−
0
View file @
3311b143
const
message
=
document
.
getElementById
(
'
message
'
);
// ✅ GET the value of textarea
console
.
log
(
message
.
value
);
// 👉️ ""
// --------------------------------------
// ✅ SET the value of the textarea
message
.
value
=
'
Hello world!
'
;
// --------------------------------------
// ✅ Append to the value of textarea
message
.
value
+=
'
Appended text.
'
;
// --------------------------------------
// ✅ get the value of textarea on change
message
.
addEventListener
(
'
input
'
,
function
handleChange
(
event
)
{
console
.
log
(
event
.
target
.
value
);
});
// Define the API URL
const
runQuery
=
'
http://localhost:8080/run
'
;
const
data
=
{
query
:
'
<P>[A,B]>(<S>[C < 0](R))
'
,
bag
:
'
false
'
,
};
const
requestOptions
=
{
method
:
'
POST
'
,
headers
:
{
'
Content-Type
'
:
'
application/json
'
},
body
:
JSON
.
stringify
(
data
),
};
// Make a GET request
fetch
(
runQuery
,
requestOptions
)
.
then
(
response
=>
{
if
(
!
response
.
ok
)
{
throw
new
Error
(
'
Network response was not ok
'
);
}
return
response
.
json
();
})
.
then
(
data
=>
{
message
.
value
=
JSON
.
stringify
(
data
,
null
,
2
);
})
.
catch
(
error
=>
{
console
.
error
(
'
Error:
'
,
error
);
});
This diff is collapsed.
Click to expand it.
src/main/java/uk/ac/ed/pguaglia/real/runtime/WebApp.java
+
5
−
2
View file @
3311b143
...
...
@@ -3,13 +3,16 @@ package uk.ac.ed.pguaglia.real.runtime;
import
org.antlr.v4.runtime.RecognitionException
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.CrossOrigin
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
uk.ac.ed.pguaglia.real.lang.Expression
;
import
uk.ac.ed.pguaglia.real.lang.ReplacementException
;
@CrossOrigin
(
origins
=
"http://localhost:8080"
,
maxAge
=
3600
)
@SpringBootApplication
@RestController
public
class
WebApp
{
...
...
@@ -18,7 +21,7 @@ public class WebApp {
SpringApplication
.
run
(
WebApp
.
class
,
args
);
}
@
Ge
tMapping
(
"/run
"
)
@
Reques
tMapping
(
method
=
RequestMethod
.
GET
,
path
=
"/{id}
"
)
public
String
run
(
@RequestParam
(
"query"
)
String
query
,
@RequestParam
(
name
=
"bag"
,
required
=
false
,
defaultValue
=
"false"
)
boolean
bag
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment