AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Sparrow: AHK WebServer w/ AHK in HTML support (sources incl)
Goto page 1, 2, 3, 4, 5, 6, 7  Next
 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
DerRaphael



Joined: 23 Nov 2007
Posts: 704
Location: % ( RegExMatch( A_AppData, "^(?P<_Home>.*)\\", A ) ? A_Home : "" )

PostPosted: Wed Sep 24, 2008 7:20 am    Post subject: Sparrow: AHK WebServer w/ AHK in HTML support (sources incl) Reply with quote


    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: svn://autohotkey.net/sparrow/core - a detailed help on howto SVN look here: http://sparrow.wikia.com/wiki/SVN_Howto)

    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 http://localhost:81/index.hkml) 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 Smile
    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 Smile


The Start UI

(Welcomescreen)

Example dump

(provoked HKML Script Compilationerror)

Demonstration of Status Overview

(show environment System-Variables)

Cool
[/list]

Feedback welcome!
_________________
    Code:
    /* no comment */


Last edited by DerRaphael on Fri May 22, 2009 12:48 am; edited 7 times in total
Back to top
View user's profile Send private message
Guest






PostPosted: Wed Sep 24, 2008 7:32 am    Post subject: Re: Sparrow an AHK based WebServer w/ native AHK in HTML sup Reply with quote

DerRaphael wrote:
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.
Back to top
DerRaphael



Joined: 23 Nov 2007
Posts: 704
Location: % ( RegExMatch( A_AppData, "^(?P<_Home>.*)\\", A ) ? A_Home : "" )

PostPosted: Wed Sep 24, 2008 7:43 am    Post subject: Reply with quote

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
_________________
    Code:
    /* no comment */
Back to top
View user's profile Send private message
n-l-i-d
Guest





PostPosted: Wed Sep 24, 2008 8:10 am    Post subject: Reply with quote

Very cool! Cool
Back to top
LiquidGravity
Guest





PostPosted: Wed Sep 24, 2008 12:28 pm    Post subject: Reply with quote

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.
Back to top
DerRaphael



Joined: 23 Nov 2007
Posts: 704
Location: % ( RegExMatch( A_AppData, "^(?P<_Home>.*)\\", A ) ? A_Home : "" )

PostPosted: Wed Sep 24, 2008 1:18 pm    Post subject: Reply with quote

LiquidGravity wrote:
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 http://localhost:81/

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:

Code:

<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:
Code:

<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 Wink ), 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
_________________
    Code:
    /* no comment */
Back to top
View user's profile Send private message
LiquidGravity
Guest





PostPosted: Wed Sep 24, 2008 3:48 pm    Post subject: Reply with quote

DerRaphael wrote:
Right now, doing some code like:
Code:

<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.org/wiki/Heredoc#Programming_languages

Example:
Code:

<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>
Back to top
tank



Joined: 21 Dec 2007
Posts: 2396
Location: Louisville KY USA

PostPosted: Wed Sep 24, 2008 4:04 pm    Post subject: Reply with quote

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?
_________________
Basic Webpage Controls with JavaScript / COM - Tutorial by Jethrow
Back to top
View user's profile Send private message
DerRaphael



Joined: 23 Nov 2007
Posts: 704
Location: % ( RegExMatch( A_AppData, "^(?P<_Home>.*)\\", A ) ? A_Home : "" )

PostPosted: Wed Sep 24, 2008 4:30 pm    Post subject: Reply with quote

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:
Code:
; 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:
Code:
<?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
Code:
test(
(Join`n
this
is
a
test
))

test(what)
{
   msgbox %what%
}

working!
Code:
test(
(Join`n
"this
is
a
test"
))

test(what)
{
   msgbox %what%
}



greets
dR

edit added mo' example codes Smile
_________________
    Code:
    /* no comment */
Back to top
View user's profile Send private message
Guest






PostPosted: Wed Sep 24, 2008 5:12 pm    Post subject: Reply with quote

Shocked

OMG

Thats pretty amazing ! Woot

Wink Too bad its a teaser yet I would love too play with it.
Back to top
ABCza



Joined: 03 Jun 2008
Posts: 26
Location: Italy

PostPosted: Thu Sep 25, 2008 6:01 pm    Post subject: Reply with quote

WTF this is ****' awesome! Nice, nice, nice Very Happy
_________________
ABCza
Back to top
View user's profile Send private message MSN Messenger
DerRaphael



Joined: 23 Nov 2007
Posts: 704
Location: % ( RegExMatch( A_AppData, "^(?P<_Home>.*)\\", A ) ? A_Home : "" )

PostPosted: Fri Sep 26, 2008 3:38 am    Post subject: Reply with quote


    Sources released - sorry for delay have had to write at least some docu Very Happy

    boys and girls, have fun with ur new toy!

    u can also click on the image (sparrow logo) to access the download

    greets
    dR

_________________
    Code:
    /* no comment */


Last edited by DerRaphael on Fri Sep 26, 2008 4:18 am; edited 1 time in total
Back to top
View user's profile Send private message
trik



Joined: 15 Jul 2007
Posts: 1316

PostPosted: Fri Sep 26, 2008 3:55 am    Post subject: Reply with quote

I just love this! I'm going to try to integrate a bunch of functions into it right now.
_________________
Religion is false. >_>


Last edited by trik on Fri Sep 26, 2008 4:26 am; edited 1 time in total
Back to top
View user's profile Send private message
DerRaphael



Joined: 23 Nov 2007
Posts: 704
Location: % ( RegExMatch( A_AppData, "^(?P<_Home>.*)\\", A ) ? A_Home : "" )

PostPosted: Fri Sep 26, 2008 4:21 am    Post subject: Reply with quote

added a lil download counter .... sorry for any inconvinience Smile

greets
dR
_________________
    Code:
    /* no comment */
Back to top
View user's profile Send private message
tank



Joined: 21 Dec 2007
Posts: 2396
Location: Louisville KY USA

PostPosted: Fri Sep 26, 2008 12:26 pm    Post subject: Reply with quote

beautiful i will be doing a php module for you i just had a long week
_________________
Basic Webpage Controls with JavaScript / COM - Tutorial by Jethrow
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Goto page 1, 2, 3, 4, 5, 6, 7  Next
Page 1 of 7

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group