The ScriptBasic Application Web Server (sbhttpd) is written in C, multi-threaded and embeds ScriptBasic as its scripting engine. It is typically used as a proxy server with Apache / Nginx as its front end. The following
echo script shows the CGI information available to ScriptBasic with requests.
echo on AWS (https://sbqbo.org/home/qbo/echo)
' CGI Echo
GLOBAL CONST nl = "\n"
CONST NumberOfCookies = 3
INCLUDE cgi.bas
' sessionid = mt::NewSessionId()
OPTION cgi$Method cgi::Get OR cgi::Post
cgi::Header 200,"text/html"
FOR i = 1 TO NumberOfCookies
' cookie(i) is i, no domain is defined, path is /, expires after 10 seconds, not secure
cgi::SetCookie "cookie" & i, i, undef, "/", gmtime() + 10, false
NEXT
cgi::FinishHeader
'-------------------------------------------------------
PRINT """
<HTML>
<HEAD>
<title>CGI Echo</title>
</HEAD>
<BODY><font face="VERDANA" size="2">
<H1>View CGI Parameters</H1>
This page shows the CGI parameters the way it was uploaded.
<!-- here is the result of the previous HTTP request -->
<FONT SIZE="3">
<PRE>
CGI system variables
--------------------
"""
' PRINT "Session ID = ", sessionid, nl
PRINT "ServerSoftware = ", cgi::ServerSoftware(), nl
PRINT "ServerName = ", cgi::ServerName(), nl
PRINT "GatewayInterface= ", cgi::GatewayInterface(),nl
PRINT "ServerProtocol = ", cgi::ServerProtocol(), nl
PRINT "ServerPort = ", cgi::ServerPort(), nl
PRINT "RequestMethod = ", cgi::RequestMethod(), nl
PRINT "PathInfo = ", cgi::PathInfo(), nl
PRINT "PathTranslated = ", cgi::PathTranslated(), nl
PRINT "ScriptName = ", cgi::ScriptName(), nl
PRINT "QueryString = ", cgi::QueryString(), nl
PRINT "RemoteHost = ", cgi::RemoteHost(), nl
PRINT "RemoteAddress = ", cgi::RemoteAddress(), nl
PRINT "AuthType = ", cgi::AuthType(), nl
PRINT "RemoteUser = ", cgi::RemoteUser(), nl
PRINT "RemoteIdent = ", cgi::RemoteIdent(), nl
PRINT "ContentType = ", cgi::ContentType(), nl
PRINT "ContentLength = ", cgi::ContentLength(), nl
PRINT "UserAgent = ", cgi::UserAgent(), nl
PRINT "Cookie = ", cgi::RawCookie(), nl
PRINT "Referer = ", cgi::Referer(), nl
PRINT "Password = ", Environ("HTTP_PASSWORD"), nl
PRINT "Full auth string= ", Environ("HTTP_AUTHORIZATION"), nl
PRINT "\nCookies:\n"
FOR i = 1 TO NumberOfCookies
PRINT "cookie" & i, " ", cgi::Cookie("cookie" & i), "\n"
NEXT
IF cgi::RequestMethod() = "GET" THEN
PRINT "GET text field using GetParam(\"TEXT-GET\") is ", cgi::GetParam("TEXT-GET"), nl
END IF
IF cgi::RequestMethod() = "POST" THEN
PRINT "POST text field using PostParam(\"TEXT-POST\") is ", cgi::PostParam("TEXT-POST"), nl
END IF
PRINT """
</PRE>
<TABLE>
<TR>
<TD BORDER=0 BGCOLOR="EEEEEE">
<PRE>
A simple form to POST parameters:<BR>
<FORM METHOD="POST" ACTION="/home/echo">
<INPUT TYPE="TEXT" VALUE="Default POST Field Text" NAME="TEXT-POST">
<INPUT TYPE="SUBMIT" NAME="SUBMIT-BUTTON" VALUE=" POST ">
</FORM>
</PRE>
</TD>
<TD BORDER=1 width="20"> </TD>
<TD BORDER=0 BGCOLOR="EEEEEE">
<PRE>
A simple form to GET parameters:<BR>
<FORM METHOD="GET" ACTION="/home/echo">
<INPUT TYPE="TEXT" VALUE="Default GET Field Text" NAME="TEXT-GET">
<INPUT TYPE="SUBMIT" NAME="SUBMIT-BUTTON" VALUE=" GET ">
</FORM>
</TD>
</TR>
</TABLE>
</BODY>
</HTML>
"""
END
ScriptBasic Web Server Features- Written in C with a footprint of < 900 KB
- Multi-threaded memory model that can share variables between threads
- Memory based session management
- ScriptBasic as the scripting language with all its extensions supported.
- Unlimited scalability
- Bootstrap is used as the UI framework with no need for dependencies
- JSON to ScriptBasic multi-level associative arrays greatly simplifies data handling.
- SQLite memory DB reduces data formatting of raw data from external sources
I have created a
Bootstrap / ScriptBasic example I use to show QBO clients that require custom interfaces and apps. This is running on my AWS EC2 hosting instance. Bootstrap is mobile centric so give a try on your laptop and phone.
Bootstrap Framework Example (https://sbqbo.org/home/qbo_main)