(PB's) CGI implemented in "standard" web?

Everything else that doesn't fall into one of the other PB categories.
User avatar
bbanelli
Enthusiast
Enthusiast
Posts: 544
Joined: Tue May 28, 2013 10:51 pm
Location: Europe
Contact:

(PB's) CGI implemented in "standard" web?

Post 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 :D) 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?
"If you lie to the compiler, it will get its revenge."
Henry Spencer
https://www.pci-z.com/
User avatar
the.weavster
Addict
Addict
Posts: 1581
Joined: Thu Jul 03, 2003 6:53 pm
Location: England

Re: (PB's) CGI implemented in "standard" web?

Post 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.
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Re: (PB's) CGI implemented in "standard" web?

Post 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).
I may look like a mule, but I'm not a complete ass.
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8452
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Re: (PB's) CGI implemented in "standard" web?

Post by netmaestro »

Ha, look who's not dead!
BERESHEIT
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Re: (PB's) CGI implemented in "standard" web?

Post 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! :)
I may look like a mule, but I'm not a complete ass.
Fred
Administrator
Administrator
Posts: 18396
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: (PB's) CGI implemented in "standard" web?

Post by Fred »

Or use Postgresql which is natively supported by PB :)
User avatar
the.weavster
Addict
Addict
Posts: 1581
Joined: Thu Jul 03, 2003 6:53 pm
Location: England

Re: (PB's) CGI implemented in "standard" web?

Post 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.
User avatar
bbanelli
Enthusiast
Enthusiast
Posts: 544
Joined: Tue May 28, 2013 10:51 pm
Location: Europe
Contact:

Re: (PB's) CGI implemented in "standard" web?

Post 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).
"If you lie to the compiler, it will get its revenge."
Henry Spencer
https://www.pci-z.com/
Post Reply