lis128 has asked for the wisdom of the Perl Monks concerning the following question:
hello fellow monks
From long time i've been developing little Perl programs to do some stuff. As i do often (ab)use other REST apis to scrap data i need, i am familiar with Curl blessings, i know how to perform simple GET or trick certain endpoint to POST him given payload to receive wanted answer. Until now it almost always happened in console, where requested informations were thrown out to STDOUT. Simple stuff
But my programs always lacked a crossplatform, human friendly web interface. Now i wanted to change this and write my own API (simple DB selects, some system() executions) and send AND receive response in browser
So i started Apache, made it capable of running CGI scripts and wrote some simple "parse url arguments and return json" procedures. it works, cool.
Problem arose when i tried to use same set of tools to run my "frontend". My "webui" consists of single form with textarea and submit button. Action is targetted against my api. So i fill textarea, press submit and... i get raw json response in my browser.
Question is:
How do i separate "api" from "frontend" and made them pass data between each other in order to
- have nice form
- have api to do actual job
- receive data from api in json format, process it and return output to user in "web format", like a table?
i deliberately am trying to avoid javascript and other node.js-junk, as i don't want to have anything in common with JS ;p
my first idea was to include some sort of www-client (like LWP) in my "fronted" to do request on my behalf, capture "api's" output and process it, but it seems like big overkill for me to have Apache running CGI script which "embeds" www client which requests data from other apache instance.
My other idea (utilizing forms) was to submit to the same page (my fronted) and check wheter request was caused by form submission (then do www-client magic) or just by entering site "for the first time to fill the form".
Both solutions feels clunky to me, so here i am, seeking a wisdom ;)
My frontend doesn't have to be pretty, "responsive" and "modern". I just want to be able to click my buttons using browser in phone, tablet and computer, simpler the better in my case
Also separation is important as i want to develop only my "backend" features, while focusing as little as possible on frontend. Seriously, form with button and optional checkboxes is something which will satisfy me as this point
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: a simple web front end
by hippo (Archbishop) on Oct 27, 2020 at 22:09 UTC | |
by lis128 (Acolyte) on Oct 28, 2020 at 09:04 UTC | |
by hippo (Archbishop) on Oct 28, 2020 at 09:40 UTC | |
Re: a simple web front end
by haukex (Archbishop) on Oct 28, 2020 at 21:07 UTC | |
Re: a simple web front end
by tobyink (Canon) on Oct 27, 2020 at 21:42 UTC | |
by lis128 (Acolyte) on Oct 28, 2020 at 09:21 UTC | |
by tobyink (Canon) on Oct 28, 2020 at 12:31 UTC | |
by bliako (Abbot) on Oct 30, 2020 at 08:11 UTC | |
Re: a simple web front end
by bliako (Abbot) on Oct 30, 2020 at 08:59 UTC |