Sparrow: AHK WebServer w/ AHK in HTML support (sources incl)
Started by
derRaphael
, Sep 24 2008 07:20 AM
106 replies to this topic
Sparrow goes community
NEW!! Sparrow wiki
A wiki for sparrow can be found here: http://sparrow.wikia.com/
Also sparrow gone SVN (to be found here: <!-- m -->http://sparrow.wikia...i/SVN_Howto<!-- m -->)
As many asked if i can make sparrow being a true community project with a decentralized version control system (aka SVN) and a wiki page, well here we go.
A roadmap will follow
Interested folks, please drop me either a note or mail me at derRaphael-at-oleco-dot-net so i can setup developer accounts for SVN.
Also if anybody is interested in contributing (whatever is available, help to spread the word and make sparrow fly) just join me and get a part of the developer crew.
many different talents are needed such as wiki maintenance, arts, hkml development, html development, bug tracking, support etc etc ...
Thx
DerRaphael - May, 20th 2009
AHK Sparrow Initial Release 0.1.3
Sparrow is a webserver completly written in AHK, which nativly supports AHK scrips being embedded in HTML. So called HKML files (pronounce H-Key-ML). The results are sent back to requested browser.
Download Sparrow-0.1.3.7z
The documentation is included in the 7zip file. it'd be too huge to write it all here.
JumpStart: Download the file, extract it (rename the folder if u like) start the script with the name sparrow.core.ahk open ur browser and type in lh (it autoexpands to <!-- m -->http://localhost:81/index.hkml<!-- m -->) press enter and enjoy.
1st AID - Trouble Shooting: Bind to different IP address ... open file sparrow.settings.ahk and look for 0.0.0.0 change it to an IP of your choice (likely 127.0.0.1) also check if port 81 is free might be neccessary to change this one, too (same file) save and restart ( if sparrow is running hit ctrl+f12 to reload the server )
this script is using named pipes and wont run in windows 9x
been successfully tested on ahk 1.0.47.5 (winxp sp2) and ahk 1.0.47.6 (win2k sp4) and yes, it does serves pages into the net if u allow it
Note: This version has been reported to work with Vista, too. (Thx, ChalamiuS)
AHKWebserver Sparrow: here are some teaser Screenshots of the Webserver in action
The Start UI
(Welcomescreen)
Example dump
(provoked HKML Script Compilationerror)
Demonstration of Status Overview
(show environment System-Variables)
8)
[/list]
Feedback welcome!
#1
-
Posted 24 September 2008 - 07:20 AM
All scripts, unless otherwise noted, are hereby released under CC-BY
Sparrow is a webserver completly written in AHK, which nativly supports AHK scrips being embedded in HTML. So called HKML files (pronounce H-Key-ML). The results are sent back to requested browser.
I think AHK (as a language) is not really suited for writing serious web applications, but the concept is really cool nevertheless.
#2
-
Posted 24 September 2008 - 07:32 AM
the goal is to have a usable api, to support AHK Scripts producing native webpages. which comes in handy for scrips, which are in need of remote control. this is a very early alpha state of the software showing - as a proof of concept - that this actually works.
also having smaller sites, which need to run off a webserver, can be realized with this. (like CDROM Productions etc)
it is not meant to replace existing webserver solutions. for a production webserver, i still prefer unixoid based OS instead of windows.
greets
dR
also having smaller sites, which need to run off a webserver, can be realized with this. (like CDROM Productions etc)
it is not meant to replace existing webserver solutions. for a production webserver, i still prefer unixoid based OS instead of windows.
greets
dR
#3
-
Posted 24 September 2008 - 07:43 AM
All scripts, unless otherwise noted, are hereby released under CC-BY
Very interesting.
So does this work like a server side VBScript or PHP? Maybe I am wrong in this interpretation. What kind of security does it have? Could you post about its functions too.
So does this work like a server side VBScript or PHP? Maybe I am wrong in this interpretation. What kind of security does it have? Could you post about its functions too.
#5
-
Posted 24 September 2008 - 12:28 PM
Very interesting.
So does this work like a server side VBScript or PHP? Maybe I am wrong in this interpretation. What kind of security does it have? Could you post about its functions too.
1st of all its a script which is written in pure ahk, running this script, you may access content hosted there by typing <!-- m -->http://localhost:81/<!-- m -->
There is a Script called "Sparrow.Core.ahk" This one works as the standard webserver, In the server settings you have an option to tell if hkml files being interpreted. when turnoed to on, and being requested from the webserver, it will load the whatvernameithas.hkml file and starts interpreting
its content.
it looks for sections enclosed in <?ahk ?> brackets.
The content of such a tag is - you guess it a plain AHK script. so a basic HKML script would look like this:
<html> <head> <title>HKML TestFile</title> </head> <body> <?ahk echo("Hello World from AHK embedded in HTML") ?> </body> </html>
of course these sections may include more than just one command. you can even use include files - not directly, a particular include directory has to be specified, so a direct access to includefiles is not possible.
atm the server is in a very early stage. the script are not checked. nor is its content. from what i canm say a path traversal hack wont work, but is not fully exploited yet.
each scriplet has a set of one-way global accessible variables. that means, each script gets a fresh copy of selected serverside variables but is not abled to change these back on server. these variables have a $_ prefix and come in different categories:
$_GET variables which include any passed variables sent with teh request
$_POST variables, from any forms uploaded
$_FILES (not fully working atm)
$_SERVER variables which have some vital information like referrer etc.
the server accepts POST and GET requests. File transfers will be possible, but are disabled for now (the server crashes, thats why)
if u ever done something in PHP, you will find, that requests posted (aswell as set via get) are stored flobally in $_GET[Varname] Variables
Same with $_POST[Varname]
On my list i have things like header injection - so the servers header content can be changed from within a script, superglobals - variables, that will be accessible from different code segments on _ONE_ hkml file.
Right now, doing some code like:
<html> <head> <title>HKML TestFile</title> </head> <body> <?ahk a := 5 ?> <p>Some HTML content</p> <?ahk echo(a) ?> </body></html>
will simply not work - technically these are two scripts and run in seperate adress spaces. i need to resetup my IPC so server works as a variable buffer for scripts. along with that, cookie-session management and header injection will become possible.
php or asp like vbs wont work, unless someone writes a wrapper for that.
i have setup a technical demo, which is also seen from the screenshot above, showing environment variables in a hkml file which were accessed at runtime of the script - not at that from server. besides each script may do whatever AHK script can do. control applications, create GUIS (no these are not send back to client, 'd be cool though ), whatever ... all GUI actions will physically happen on the server. the client only receives the html (content whatever) you sent back to it.
it is not working atm, but i have plans to include a demo showing how to use GDI+ libraries to dynamically create graphics on the fly and send these back to client.
there is a basic interface for a plugin structure but this needs more imporvement, so plugins may be loaded at runtime (enabled or disabled)
so far .. most of the stuff i have written here will also be readable in the documentation which will be accessible from standard welcome page
more to come
greets
DerRaphael
#6
-
Posted 24 September 2008 - 01:18 PM
All scripts, unless otherwise noted, are hereby released under CC-BY
Right now, doing some code like:
<html> <head> <title>HKML TestFile</title> </head> <body> <?ahk a := 5 ?> <p>Some HTML content</p> <?ahk echo(a) ?> </body></html>
will simply not work - technically these are two scripts and run in seperate adress spaces. i need to resetup my IPC so server works as a variable buffer for scripts. along with that, cookie-session management and header injection will become possible.
I would leave it treat that like two separate scripts and instead use a heredoc method to output the HTML content in between. See http://en.wikipedia.... ... _languages
Example:
<html> <head> <title>HKML TestFile</title> </head> <body> <?ahk a := 5 echo <<<HERE <p>Some HTML content</p> <p>Some more HTML content</p> HERE; echo(a) ?> </body></html>
#7
-
Posted 24 September 2008 - 03:48 PM
dangit now i have to write a php wrapper
luckily php supports command line html parsing
I will post it later tonight or tomorrow wont take long
i fill approach it as tho the ahk script output is created prior to phpbeing called
thoughts?
probably wrap mysql in it as well ...thoughts on this?
luckily php supports command line html parsing
I will post it later tonight or tomorrow wont take long
i fill approach it as tho the ahk script output is created prior to phpbeing called
thoughts?
probably wrap mysql in it as well ...thoughts on this?
#8
-
Posted 24 September 2008 - 04:04 PM
Never lose.
WIN or LEARN.
WIN or LEARN.
implementing heredoc alike techniques wont be possible unless the script parser will be rewritten.
however it is possible using a similar attempt either by using the echo() wrapper or writing directly out to stdout by using fileappend and ahk continuation sections. it will be cleaner using echo(), since fileappend is subject to change in future releases.
currently echo() is a simple wrapper for fileappend and looks like this:
so a translated heredoc attempt using echo 'd look like this:
i just checked out of curiosity, how continuation sections 'd work directly with parameters when calling a function, here's what i learned
not working
greets
dR
edit added mo' example codes
however it is possible using a similar attempt either by using the echo() wrapper or writing directly out to stdout by using fileappend and ahk continuation sections. it will be cleaner using echo(), since fileappend is subject to change in future releases.
currently echo() is a simple wrapper for fileappend and looks like this:
; This needs to be tested with binary raw data echo(string,length=0) { FileAppend,%string%,* }As u can see, there is a length parameter included which might be used for raw binary data lateron
so a translated heredoc attempt using echo 'd look like this:
<?ahk a := 5 b= (LTrim Join<br>`n What I always wanted to do: Writing my own webserver, supporting the scripting language of my choice. <strong>Hey! I did that already!!</strong> ) echo(b) echo(a) ?>
i just checked out of curiosity, how continuation sections 'd work directly with parameters when calling a function, here's what i learned
not working
test( (Join`n this is a test )) test(what) { msgbox %what% }working!
test( (Join`n "this is a test" )) test(what) { msgbox %what% }
greets
dR
edit added mo' example codes
#9
-
Posted 24 September 2008 - 04:30 PM
All scripts, unless otherwise noted, are hereby released under CC-BY
:shock:
OMG
Thats pretty amazing ! Woot
:wink: Too bad its a teaser yet I would love too play with it.
OMG
Thats pretty amazing ! Woot
:wink: Too bad its a teaser yet I would love too play with it.
#10
-
Posted 24 September 2008 - 05:12 PM
WTF this is ****in' awesome! Nice, nice, nice
#11
-
Posted 25 September 2008 - 06:01 PM
All my scripts/snippets are released under the WTFPL: http://sam.zoy.org/wtfpl/COPYING
Sources released - sorry for delay have had to write at least some docu
boys and girls, have fun with ur new toy!
u can also click on the image (sparrow logo) to access the download
greets
dR
#12
-
Posted 26 September 2008 - 03:38 AM
All scripts, unless otherwise noted, are hereby released under CC-BY
I just love this! I'm going to try to integrate a bunch of functions into it right now.
#13
-
Posted 26 September 2008 - 03:55 AM
Religion is false. >_>
added a lil download counter .... sorry for any inconvinience
greets
dR
greets
dR
#14
-
Posted 26 September 2008 - 04:21 AM
All scripts, unless otherwise noted, are hereby released under CC-BY
beautiful i will be doing a php module for you i just had a long week
#15
-
Posted 26 September 2008 - 12:26 PM
Never lose.
WIN or LEARN.
WIN or LEARN.