fortran-lang / playground

An interactive Fortran playground
MIT License
34 stars 12 forks source link

API #49

Closed zmoon closed 2 years ago

zmoon commented 2 years ago

Is this example from the readme

curl \
  --location \
  --request POST '127.0.0.1:5000/run' \
  --header 'Content-Type: application/json' \
  --data-raw '{
    "code": "program hello\r\n  print *, 'Hello, World!'\r\nend program hello\r\n",
    "programInput": "",
    "libs" : []
}'

supposed to work with https://play.fortan-lang.org? I tried but get a response of

<html>
<head><title>405 Not Allowed</title></head>
<body bgcolor="white">
<center><h1>405 Not Allowed</h1></center>
</body>
</html>

Wondering about linking code samples in FortranTipBrowser to this playground. I guess what would be more useful for that would be being able to pass the script in URL query parameters, as is possible with Godbolt.

milancurcic commented 2 years ago

No, but try with https://play-api.fortan-lang.org.

After #34 is implemented, you'll need to set the Origin: play.fortran-lang.org header in the request for it to be accepted.

zmoon commented 2 years ago

No, but try with https://play-api.fortan-lang.org/.

Thanks, here is the updated example for reference:

curl \
  --location \
  --request POST 'https://play-api.fortran-lang.org/run' \
  --header 'Content-Type: application/json' \
  --data-raw '{
    "code": "program hello\r\n  print *, \"Hello, World!\"\r\nend program hello\r\n",
    "programInput": "",
    "libs" : []
}'

:point_up: I did have to change the quoting of "Hello, World!" for it to work for me

milancurcic commented 2 years ago

Good catch, do you mind a quick PR to fix the snippet in the README? Thanks!