Soft Serve: A simple-to-use HTML server
Phil Pilgrim (PhiPi)
Posts: 23,514
This is still a work-in-progress, but I thought a brief introduction might be of interest to some. I'm not going to post the object yet, since there's still some cleanup to do, but here's a brief feature set:
More later...
-Phil
- Provides a (mostly) transparent wrapper for Roy Eltham's DHCP object (as modified by Beau Schwab).
- Uses abbreviated HTML constructs for small page footprints.
- Automatically inserts linefeeds, indenting, and end tags for proper nesting and nice visual source presentation.
- Permits the embedding of string variables anywhere in the output. As the output is being generated, data are fetched from the strings, fill-in-the-blanks style.
- Has methods for request-string and HTML-source echoing for ease of debugging.
- Automatically parses GET requests into action string and key/value parameter pairs.
[font=Parallax][size=2] CON _clkmode = xtal1 + pll16x _xinfreq = 5_000_000 #$00, EOF,LEFT,CENTER,CHECKED,TEXT,SUBMIT,RESET,RADIO,BUTTON,HIDDEN,EOL,EOP,HR,SP,LI,SIZE, { } FIL,CHKBOX,POST,ALIGN,NAME,VALUE,CLASS,ID,STYLE_,TYPE,WIDTH,HEIGHT,COLOR,FONT,FSIZE,BKGND #$80, B_,I_,U_,S_,SUP_,SUB_,SPAN_,TABLE_,TR_,TD_,DIV_,FORM_,INPUT_,IMG_,URL_,LIST_, { } CODE_,PRE_,OLIST_,INDENT_,RESERVED2,VAR_,ATTR_,HTML_,MARK_,VAL_,_STYLE,_ATTR,_HTML,_MARK,_TAG,_ALL QU = $22 VISITOR = 1 TITLE_COLOR = 2 OBJ server : "soft_serve" num : "simple_numbers_plus" VAR word request, variables[32], visitor_no PUB main server.start(string("192.168.0.50:3456"), string("192.168.0.4"), 0, string("00 08 DC 16 F0 13")) server.setvars(@variables) variables[TITLE_COLOR] := string("blue") repeat if (strcomp(request := server.request, string("/change"))) variables[TITLE_COLOR] := server.param(string("color")) else variables[TITLE_COLOR] := string("blue") variables[VISITOR] := num.dec(++visitor_no) server.html_page(string("Color Change Test"), 0, string("#fffff0")) server.html_content(@change) server.end_html_page DAT change byte IMG_,"http://forums.parallax.com/image.php?u=45432",_ATTR byte HR,DIV_,ALIGN,CENTER,COLOR,VAR_,TITLE_COLOR,FSIZE,"20pt",FONT,"sans-serif",_ATTR,B_ byte "This title is colored ",VAR_,TITLE_COLOR,".",_ALL,HR byte DIV_,CENTER,WIDTH,"400",BKGND,"#e0e0d0;margin:auto auto;padding:12pt;border:solid ",VAR_,TITLE_COLOR," 1px",_ATTR byte FORM_,"/change",_ATTR,"Enter a new color here: " byte INPUT_,TEXT,NAME,"color",VALUE,VAR_,TITLE_COLOR,SIZE,"10",_ATTR," " byte INPUT_,SUBMIT,_ATTR,EOP byte "You are visitor number ",VAR_,VISITOR,".",EOF [/size][/font]You can give this program a try here (for awhile):
[url]phipi.homelinux.org:3456[/url]
I think I've got my firewall set right, but let me know if you can't reach it; and be sure to view the source to compare with the above DAT section.More later...
-Phil
Comments
'
I was vistor 101
Thanks,
-Phil
John Abshier
ps. I tried to stump it with fuchsia for the color, but it got it!
You can also enter colors in their RGB hex format, #RRGGBB, e.g. #FFFF00 for yellow.
-Phil
If your really using the DHCP methods in Roy's code, that's fine. I might have overstepped my boundry by taking his code and wrapping it the way I did when really I was only using it for basic. HTML ... Sorry Roy.
Attached is a bare bones 'Simple HTML.Spin' wrapper that should have been what I originally posted. this should work in place of the 'DHCP_GBSbuild_01_27_2001.spin'
-Phil