Page 1 of 1
(PB's) CGI implemented in "standard" web?
Posted: Sun Nov 22, 2015 9:26 pm
by bbanelli
Greetings to all,
there should be "lame" tag for this kind of questions, so please forgive my ignorance, but I was wandering if CGI is suitable for implementing within something like Bootstrap?
Basically, would it be possible to invoke CGI script and than embed it results in some other HTML/CSS visualization? To be more precise, what I'm wandering is whether one should embed "design" part within CGI script, or can standard HTML/CSS/JS combination can be created, calling CGI as one would call a PHP script, for example?
To make my question even more precise, I would use CGI to access SQLite database on web server where user would simple input username and get some data accordingly. In addition, I suppose multithreading for CGI script isn't really necessary in terms of multiple users accessing script, when each instance is run separately for each web request?
Thank you in advance,
Bruno
Edit: as usually, asking Google all the right questions (which were a bit hard for me

) gave some insight.
So, as far as I've understood, using
SHTML extension and "#include virtual" command. "#exec" doesn't work on my server, but parameters work fine, so I guess I don't have to worry about that?
Re: (PB's) CGI implemented in "standard" web?
Posted: Mon Nov 23, 2015 6:58 am
by the.weavster
bbanelli wrote:Basically, would it be possible to invoke CGI script and than embed it results in some other HTML/CSS visualization? To be more precise, what I'm wandering is whether one should embed "design" part within CGI script, or can standard HTML/CSS/JS combination can be created, calling CGI as one would call a PHP script, for example?
Personally I wouldn't do that (even with PHP), I'd send and receive JSON and have the client side JavaScript handle any design changes based on the data within the JSON. I like single page web applications as the front end that access an API from the back end.
bbanelli wrote:To make my question even more precise, I would use CGI to access SQLite database on web server where user would simple input username and get some data accordingly.
Yes, no problem. You should use HTTPS if your communication between client and server needs to be secure.
bbanelli wrote:In addition, I suppose multithreading for CGI script isn't really necessary in terms of multiple users accessing script, when each instance is run separately for each web request?
With CGI the web server will create a new process for each client, your CGI application will process the request, write the response and terminate so I don't really see a need for threads.
Re: (PB's) CGI implemented in "standard" web?
Posted: Tue Nov 24, 2015 9:36 pm
by srod
I'd be a little wary of using SQLite if there is the potential for multiple user requests writing to the same database file at the same time without some intermediate logic on the part of your cgi. You would normally need your own server program to queue the write requests etc, which is not going to be possible on a shared host for example.
If this is likely then perhaps consider MariaDB (MySQL).
Re: (PB's) CGI implemented in "standard" web?
Posted: Wed Nov 25, 2015 3:23 am
by netmaestro
Ha, look who's not dead!
Re: (PB's) CGI implemented in "standard" web?
Posted: Wed Nov 25, 2015 8:25 am
by srod
netmaestro wrote:Ha, look who's not dead!
I wouldn't be too sure about that; brain seems to be functioning, at least in part, but not sure about the rest!
I just dash in and out on occasion when fangles isn't looking!

Re: (PB's) CGI implemented in "standard" web?
Posted: Wed Nov 25, 2015 8:43 am
by Fred
Or use Postgresql which is natively supported by PB

Re: (PB's) CGI implemented in "standard" web?
Posted: Wed Nov 25, 2015 9:20 am
by the.weavster
srod wrote:I'd be a little wary of using SQLite if there is the potential for multiple user requests writing to the same database file at the same time without some intermediate logic on the part of your cgi. You would normally need your own server program to queue the write requests etc, which is not going to be possible on a shared host for example.
Probably the easiest way to handle that with a CGI program is to sleep briefly if you get the SQLITE_BUSY error when trying to start a transaction and then try again but also have a counter for an acceptable number of failed attempts before bailing out completely.
Re: (PB's) CGI implemented in "standard" web?
Posted: Wed Nov 25, 2015 9:46 am
by bbanelli
Hi guys,
thank you all for your feedback.
@the.weavster, thank you for the explanation and idea for SQLITE_BUSY check.
@srod&Fred, this will be (very!) low volume site, probably with less than few SELECT queries per day (no reading of whatsoever). On the other hand, I'd like to keep it simple and not mess with external libraries for MySQL (MariaDB) and Postgres is usually an issue on CPanel hosted sites due to the fact there cPanel/WHM does not distribute our own build/RPM of PostgreSQL my servers are hosted on CentOS 6 so only native support is for version 8.4 (which is old and unsupported).