Add test echo application

This commit is contained in:
Ben 2021-08-21 16:00:48 +02:00
parent 546e2ffe58
commit 87b671a21a
Signed by: ben
GPG Key ID: 0F54A7ED232D3319
3 changed files with 32 additions and 0 deletions

View File

@ -0,0 +1,17 @@
jQuery(document).ready(() => {
jQuery("#submit").click(() => {
const text = jQuery("#text").val();
console.log("Sending:", text)
fetch(OC.generateUrl('/apps/upschooling/echo'), {
method: 'POST',
body: text,
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'requesttoken': oc_requesttoken,
},
}).then(async (res) => {
console.log(res);
jQuery("#response").val(await res.text());
}).catch(console.error)
});
});

View File

@ -1,6 +1,7 @@
<?php
namespace OCA\UPschooling\Controller;
use OCP\AppFramework\Http\TextPlainResponse;
use OCP\IRequest;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\AppFramework\Http\DataResponse;
@ -28,4 +29,8 @@ class PageController extends Controller {
return new TemplateResponse('upschooling', 'index'); // templates/index.php
}
public function doEcho() {
return new DataResponse($_POST);
}
}

View File

@ -1 +1,11 @@
<h1>Hello world</h1>
<hr>
<label for="text">Text to Send:</label><input type="text" id="text">
<button id="submit">Submit</button>
<hr>
<label for="response">Response:</label>
<textarea id="response"></textarea>