Jump to content
Sign in to follow this  
Busti

AutoIT Webserver Alpha Version

Recommended Posts

Busti

Hi all, im Releasing an Alpha version of my "AutoIT-WebServer".

The Example should explane everything.

Links and Downloads don't work yet :). I Hope i get 'em working.

Example :

#include <_AutoITWEB.au3>

$aSocket = _WebServer_StartWebServer()
_WebServer_LoadHTML( @ScriptDir & "\index.html" )

While 1
    _WebServer_AcceptConnection($aSocket)
WEnd

; Dont Remove this Function, or _AutoITWEB.au3 won't work.
Func _WebServer_OnConnect($x)
    _WebServer_LoadHTML( @ScriptDir & "\index.html" ) ; reloads index.html everytime a user connects.
    _WebServer_ServerLog( "--   ]Incomming IP: "& _WebServer_ClientIP($x),1)
EndFuncoÝ÷ Ø­ ֮ݫ­¢+Ø¥¹±Õµ½¹(¥¹±Õ±ÐíMÑÉ¥¹¹ÔÌÐì(í±½°
½¹ÍѹÌ(íUÍȹÐMÑÑ¥¹Ì)±½°
½¹ÍÐÀÌØí}UMI}
!
-}%@ôÄ)±½°
½¹ÍÐÀÌØí}UMI}}%@ôÄ(í±½°¥±MÑÑ¥¹Ì)±½°
½¹ÍÐÀÌØí}%1}
IQ}1=ôÄ)±½°
½¹ÍÐÀÌØí}%1}1=}95ôÅÕ½ÐíÍÉÙȹ±½ÅÕ½Ðì)±½°
½¹ÍÐÀÌØí}%1}YIM%=8ôÅÕ½ÐìÀ¸ÀıÁ¡ÅÕ½Ðì)±½°
½¹ÍÐÀÌØí}%1}Y%M%Q=I}95ôÅÕ½ÐíY¥Í¥Ñ½É̹ÐÅÕ½Ðì)±½°ÀÌØí}%1}Y%M%Q=ILô¥±I ÀÌØí}%1}Y%M%Q=I}95¤)±½°ÀÌØí}%1}M
I%AQ}Q%Q1ôÅÕ½ÐìÅÕ½Ðì)±½°ÀÌØí}%1}!Q51} =dôÅÕ½ÐìÅÕ½Ðì)±½°ÀÌØí}%1}!Q50ôÅÕ½ÐìÅÕ½Ðì)±½°ÀÌØí}%1}UM%9}%1ôÀ)±½°ÀÌØíUÍÉ¥±ôÅÕ½ÐíUÍȹÐÅÕ½Ðì°ÀÌØí¹ÑÉå9µôÅÕ½Ðí%@ÅÕ½Ðì)±½°ÀÌØíM½­ÐôÀ(íMÉÙÈMÑÉеUÀ)}]MÉÙÉ}MÉÙÉ1½ ÅÕ½Ðì´´uMÑÉÑ¥¹ÕÀm    u]µMÉÙȸ ÅÕ½ÐìµÀìÀÌØí}%1}YIM%=8µÀìÅÕ½Ðì¤ÅÕ½Ðì°Ä¤()Õ¹}]MÉÙÉ}ÁÑ
½¹¹Ñ¥½¸ ÀÌØíM½­Ð¤(%±½°ÀÌØíM½­ÐôQ
AÁÐ ÀÌØíM½­Ð¤($ì!¥È­½µµÐ¹½ ÈQ¥°µ¥Ð¸%@MÙ¥¹Ñ¸(%%ÀÌØíM½­ÐÐìôÀQ¡¸($%}]MÉÙÉ}=¹
½¹¹Ð ÀÌØíM½­Ð¤($%Q
AM¹ ÀÌØíM½­Ð°ÀÌØí}%1}!Q50$¤($$ÀÌØí}%1}Y%M%Q=IL¬ôÄ($%¥±±Ñ ÀÌØí}%1}Y%M%Q=I}95¤($%¥±]É¥Ñ ÀÌØí}%1}Y%M%Q=I}95°ÀÌØí}%1}Y%M%Q=IL¤(%¹%(%IÑÕɸQ
A
±½ÍM½­Ð ÀÌØíM½­Ð¤)¹Õ¹()Õ¹}]MÉÙÉ}9Ý!ѵ° ÀÌØíà¤(%Q
AM¹ ÀÌØíà°ÀÌØí}%1}!Q50¤)¹Õ¹()Õ¹}]MÉÙÉ}1½!Q50 ÀÌØí±¥¹¬¤($ÀÌØí}%1}!Q50ô¥±I ÀÌØí±¥¹¬¤)¹Õ¹()Õ¹}]MÉÙÉ}MÑÉÑ]MÉÙÈ ÀÌØí±¥ÍѸõ%AÉÍÌÄ°ÀÌØíÁ½ÉÐôØÄÄÈ°ÀÌØí½¹¸ôÄÀÀ¤(%±½°ÀÌØí}%1}5a}
=99
Q%=9LôÀÌØí½¹¸(%±½°ÀÌØí}%1}A=IPôÀÌØíÁ½ÉÐ(%±½°ÀÌØí}%1}1%MQ9}%@ôÀÌØí±¥ÍѸ(%}]MÉÙÉ}MÉÙÉ1½ ÅÕ½Ðì´´%uQ
AMÑÉÑÕÀ ¤ÅÕ½Ðì°Ä¤(%Q
AMÑÉÑÕÀ ¤($íÁÐ%¹½µ¥¹
½¹¹Ñ¥½¹Ì(%}]MÉÙÉ}MÉÙÉ1½ ÅÕ½Ðì´´%uQ
A1¥ÍѸ ÅÕ½ÐìµÀìÀÌØí}%1}1%MQ9}%@µÀìÅÕ½Ðì°ÅÕ½ÐìµÀìÀÌØí}%1}A=IPµÀìÅÕ½Ðì°ÅÕ½ÐìµÀìÀÌØí}%1}5a}
=99
Q%=9LµÀìÅÕ½Ðì¤ÅÕ½Ðì°Ä¤($ÀÌØíM½­ÐôQ
A1¥ÍѸ ÀÌØí}%1}1%MQ9}%@°ÀÌØí}%1}A=IP°ÀÌØí}%1}5a}
=99
Q%=9L¤($ÀÌØíÙÉɽÈôÉɽÈ(%%ÀÌØíM½­Ðô´ÄQ¡¸($%}]MÉÙÉ}MÉÙÉ1½ ÅÕ½Ðì´´uÉɽȽ¸1¥¹èÅÕ½ÐìµÀìMÉ¥ÁÑ1¥¹9յȵÀìÅÕ½Ðì¼ÅÕ½ÐìµÀìMÉ¥ÁÑ9µ°Ä¤($%}]MÉÙÉ}MÉÙÉ1½ ÅÕ½Ðì´´uÉɽÈôÅÕ½ÐìµÀìÀÌØíÙÉɽȰĤ($%%ÀÌØíÙÉɽÈôÄQ¡¸($$%}]MÉÙÉ}MÉÙÉ1½ ÅÕ½Ðì´´u]ɽ¹%@ÉÍ̸ÅÕ½Ðì°Ä¤($$%}]MÉÙÉ}MÉÙÉ1½ ÅÕ½Ðì´´u½ÉÑ¥¹MÑÉиÅÕ½Ðì°Ä¤($$%IÑÕɸ´ÈíÝɽ¹¥À($%±Í%ÀÌØíÙÉɽÈôÈQ¡¸($$%}]MÉÙÉ}MÉÙÉ1½ ÅÕ½Ðì´´u]ɽ¹A½ÉиÅÕ½Ðì°Ä¤($$%}]MÉÙÉ}MÉÙÉ1½ ÅÕ½Ðì´´u½ÉÑ¥¹MÑÉиÅÕ½Ðì°Ä¤($$%IÑÕɸ´ÌíÝɽ¹Á½ÉÐ($%±Í($$%}]MÉÙÉ}MÉÙÉ1½ ÅÕ½Ðì´´%uU­¹½Ý¸ÉÉ½È ÅÕ½ÐìµÀìÀÌØíÙÉɽȵÀìÅÕ½Ðì¤ÅÕ½Ðì°Ä¤($%¹%(%±Í($%}]MÉÙÉ}MÉÙÉ1½ ÅÕ½Ðì´´%uMÉÙÈ¥Ì1¥Íѹ¥¹MÕÍÍÕ±±ä¸ÅÕ½Ðì°Ä¤($%}]MÉÙÉ}MÉÙÉ1½ ÅÕ½Ðì´´%uM½­ÐèÅÕ½ÐìµÀìÀÌØíM½­Ð°Ä¤($%IÑÕɸÀÌØíM½­Ð(%¹%)¹Õ¹()Õ¹}]MÉÙÉ}
±¥¹Ñ%@ ÀÌØíM½­Ð¤($ÀÌØí%@ô}M½­ÑQ½%@ ÀÌØíM½­Ð¤(%IÑÕɸÀÌØí%@)¹Õ¹()Õ¹}]MÉÙÉ}MÉÙÉ1½ ÀÌØíÍQáаÀÌØí͹ÑÈôÀ¤(%%ÀÌØí}%1}
IQ}1=ôÄQ¡¸($$ÀÌØíÍôÅÕ½ÐìÅÕ½Ðì($%%ÀÌØí͹ÑȱÐìÐìÀQ¡¸ÀÌØíÍô
I1($%¥±]É¥Ñ ÀÌØí}%1}1=}95°ÀÌØíÍQáеÀìÀÌØíͤ(%¹%)¹Õ¹(ìQ¡¹­ÌѼÕѽ%P!±Àµ¥±¸)Õ¹}M½­ÑQ½%@ ÀÌØíM!=
-(1½°ÀÌØíͽ­Èô11MÑÉÕÑ
ÉÑ ÅÕ½ÐíÍ¡½ÉÐíÕÍ¡½ÉÐíÕ¥¹Ðí¡ÉlátÅÕ½Ðì¤((1½°ÀÌØíIÐô11
±° ÅÕ½Ðí]ÌÉ|Ìȹ±°ÅÕ½Ðì°ÅÕ½Ðí¥¹ÐÅÕ½Ðì°ÅÕ½ÐíÑÁɹµÅÕ½Ðì°ÅÕ½Ðí¥¹ÐÅÕ½Ðì°ÀÌØíM!=
-P°|(ÅÕ½ÐíÁÑÈÅÕ½Ðì±11MÑÉÕÑÑAÑÈ ÀÌØíͽ­È¤°ÅÕ½Ðí¥¹Ñ}ÁÑÈÅÕ½Ðì±11MÑÉÕÑÑM¥é ÀÌØíͽ­È¤¤(%9½ÐÉɽȹÀÌØíIÑlÁtôÀQ¡¸(ÀÌØíIÐô11
±° ÅÕ½Ðí]ÌÉ|Ìȹ±°ÅÕ½Ðì°ÅÕ½ÐíÍÑÈÅÕ½Ðì°ÅÕ½Ðí¥¹Ñ}¹Ñ½ÅÕ½Ðì°ÅÕ½Ðí¥¹ÐÅÕ½Ðì±11MÑÉÕÑÑÑ ÀÌØíͽ­È°Ì¤¤(%9½ÐÉɽÈQ¡¸ÀÌØíIÐôÀÌØíIÑlÁt(±Í(ÀÌØíIÐôÀ(¹%((ÀÌØíͽ­ÈôÀ((IÑÕɸÀÌØíIÐ)¹Õ¹

Working Commands Yet :

_WebServer_StartWebServer($ListenIP,$Port,$MaxConnections)
_WebServer_AcceptConnection($Socket)
_WebServer_LoadHTML($File)
_WebServer_ClientIP($Socket)
_WebServer_ServerLog($Text)
_WebServer_AcceptConnection($Socket)

Have Fun ;)

PS: Test the Server on : http://wowhack.servehttp.com:6112/

Edited by Busti

My UDF's : Startet on : 06.06.2006_CaseSearchOrReplaceStr();~> Searches OR Replaces a String,;~> With or Without Casesensivity

Share this post


Link to post
Share on other sites
Busti

I'm still thinking about, how to get the link which the user clicked :)

Edited by Busti

My UDF's : Startet on : 06.06.2006_CaseSearchOrReplaceStr();~> Searches OR Replaces a String,;~> With or Without Casesensivity

Share this post


Link to post
Share on other sites
James

What do you mean?

Link the files in HTML:

<a href="myfile.txt">Download myfile.txt</a>

Then in the place where you keep your webpages (htdocs maybe) copy/create a file called myfile.txt, then when the user clicks the link it will download. Its how HTML works.

-James

Share this post


Link to post
Share on other sites
Busti

i Know, but my server wont give him the file, thats the problem...

i need something like this :

User clicks on a link, i cann see the url the user typed, extract filename, send him the filename requestet.

if the filename is not found, i send him the Errorpage.

you understand what i mean ?


My UDF's : Startet on : 06.06.2006_CaseSearchOrReplaceStr();~> Searches OR Replaces a String,;~> With or Without Casesensivity

Share this post


Link to post
Share on other sites
Busti

HTML :

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Busti's AutoIT Web-Server</title>
</head>
<body>

<center><h1>Hello, this is my Site... in AUTOIT!</h1>
<b><br><br>
See what AUTOIT! can do..!<br>
if i use a Extern File, i can change the text all the time without to restart the Server :-)<br>
You can Create a Complete Website here too :D.</b><br><br>
<font color=#FF0FF0>You can Write in Color's</font><br>
<font face="lucida console">Or Change the Font...</font><br>
<font size="6">....Size</font><br>
<font color=#FF000F face="arial">Write in Colors and Change the Font</font><br>
<font color=#F0F00F face="arial" size="2">Write in Colors and Change the Font and the Size</font><br><br>

<a href="test.rar" alt="test-file">Download File : test.rar</a><br>
<a href="index2.html">move..your...asssss!!!</a><br>
<a href="index2.html" target="_blank">test</a><br><br>
The 3 links above dont work yet... sry :(<br>
</center>
</body>
</html>

My UDF's : Startet on : 06.06.2006_CaseSearchOrReplaceStr();~> Searches OR Replaces a String,;~> With or Without Casesensivity

Share this post


Link to post
Share on other sites
jvanegmond

The problem is you are not using HTTP. You are just trying things that work, and when something goes right it is completely coincidental. Read RFC2616 for more information.

The first thing you should start on is parsing GET commands and sending back a page the proper way! Because I doubt what you are doing now works in any other browser then Internet Explorer. I know Mozilla will refuse.

By the way, I already looked up RFC2616 for you: http://www.faqs.org/rfcs/rfc2616.html

Share this post


Link to post
Share on other sites
Busti

it's working with Mozilla oO..^^

And thx, i will have a look @ it.


My UDF's : Startet on : 06.06.2006_CaseSearchOrReplaceStr();~> Searches OR Replaces a String,;~> With or Without Casesensivity

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.