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


In reply to a simple web front end by lis128

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.