View Full Version : LuaSocket: Simple Web Server
This example is a little web server that uses the LuaSocket library. It only supports GET at this time, but could easily be added upon to support POST. Build a web server of your own, use AMS as your CGI... a lot of possibilities here. Ultimately, you'd want to get the clients into an array, but I only have so long of a lunch break :)
Skills Used: Basic TCP/IP Knowlege, System.LanInfo, Input Object, Page Timer, and the Lua Socket Library
Ted Sullivan
10-06-2005, 04:51 PM
Fantastic stuff! :yes :yes :yes
It suprises me at how little code it actually takes to implement. I kinda put it off thinking it might be a lot more work. I have to say that I am pleasantly suprised :yes :yes
Corey
10-06-2005, 06:15 PM
I've had the same experience. For some of the stuff I've built in 6.0 it has been shocking how little code/time it took compared to what I had envisioned prior to the design. :yes
Dermot
10-07-2005, 02:08 AM
That is just amazing! :yes :yes and yeah so little code. :yes :yes
Corey
10-07-2005, 02:47 AM
That is just amazing!
No matter how impressed I get with Worm he always manages to quietly raise the bar a little more somehow. :)
yosik
10-07-2005, 04:15 AM
Amazing, Worm!!
Seems so easy...once YOU have done it....
Yossi
Intrigued
10-07-2005, 03:08 PM
This gets to "Swankys"!
:p
Desmond
10-07-2005, 03:09 PM
Stupendous!
Intrigued
10-07-2005, 04:53 PM
I was typing sooo fast again.
to = TWO!
*smacks self in back of head*
Mikhail
10-07-2005, 09:33 PM
No words, Master. :-)
Mikhail
10-07-2005, 09:53 PM
is possible to do a powerful and minimal p2p **** with ams + LUA (still more minimalistic than gnutella protocol v0.4),...
:eek:
Possible? Definitely!
I wasn't too sure what to expect when Brett enlightened us that we could now load the LuaSocket library with v6. Implementing the library was a lot easier than I expected. I'm not 100% sure that the way I've done this is the "best" method, but it works, so I'm not complaining.
Josué Alba
10-08-2005, 01:23 PM
YOU ARE THE GUY WORM.
:eek: :eek:
No words
playmenow
02-22-2006, 03:08 PM
it would be perfect for me if it would support php :)
it would be perfect for me if it would support php :)
Hence the name Simple Web Server
playmenow
03-03-2006, 01:24 AM
erm... include() or require() is what i need :D
okay, include the PHP DLL's, and it's going to require a lot of work :)
Sorry, couldn't resist. I have no idea on how to implement PHP into this :yes
playmenow
03-03-2006, 11:38 AM
lol..why sorry, it's funny :)
playmenow
04-01-2006, 12:27 AM
I have an idea!!!
file = TextFile.ReadToString("AutoPlay\\Docs\\file.php")
if String.Find(file, "<?php include(", 1, true) ~= 0 then
String.Replace(file, "<?php include(\"", TextFile.ReadToString("AutoPlay\\Docs\\file.html"), true);
String.Replace(file, "\"); ?>", "", true);
end
But I do'nt know how to remove this "red text": <?php include("blah.html"); ?>
P.S.: See Worm, it's possibile to include *a few* PHP functions.
If someone wants all the PHP, then it may take a few years...
playmenow
04-01-2006, 01:19 PM
Hey Worm, I found how!!!:D
Bad it's only for AMS5 (will it worm on AMS6????)...
http://indigorose.com/forums/showthread.php?t=12837 :eek:
:yes :yes :eek: :yes :yes
wasim21k
12-17-2006, 11:30 AM
hi guys nice work,
but i just can not solve this problem i m having here is in Docs folder i have index.html when i run web server it open this file but as you can see it also call one other file which is located on my c:\web\page.html and its not opening that file, am i missing something wrong? here is my index file from \My Project\CD_Root\AutoPlay\Docs\ any that might help me.
<html>
<head>
<title>Simple Web server</title>
<frameset rows="132,*">
<frame name="header" scrolling="no" noresize="noresize" target="main" src="head.html">
<frame name="main" src="file:///C:/web/page.html">
<noframes>
<body>
</body>
</noframes>
</frameset>
</body>
</html>
mrdude
12-23-2006, 06:56 AM
Nice, I like it - it would be better if you could just add files to the download folder though, and when the index.html file was loaded it automatically listed those files for download - instead of having to make a new index.html file every time a file was added to that download folder.
wasim21k
12-28-2006, 03:08 AM
hi guys, hop you are having nice christmas holidays.
well here my point is that there are some files in c:\web\page.html
it mean when i run web server it should open file from c:\web folder and i can load this file stored in \My Project\CD_Root\AutoPlay\Docs\index.html and here is code for that index.html
<html>
<head>
<title>Simple Web server</title>
<frameset rows="132,*">
<frame name="header" scrolling="no" noresize="noresize" target="main" src="head.html">
<frame name="main" src="file:///C:/web/page.html">
<noframes>
<body>
</body>
</noframes>
</frameset>
</body>
</html>
but when i run web server it loads index.html but not from c:\web folder as this index.html is a wab page should open page.html file from c:\web folder which is stored in c drive but its not opening but if i open \My Project\CD_Root\AutoPlay\Docs\index.html then it works fine i mean then it open but if i run web server and open home page its just blank just want to know what i m doing wrong here any idea?
rexzooly
08-19-2007, 07:52 AM
hi guys, hop you are having nice christmas holidays.
well here my point is that there are some files in c:\web\page.html
it mean when i run web server it should open file from c:\web folder and i can load this file stored in \My Project\CD_Root\AutoPlay\Docs\index.html and here is code for that index.html
<html>
<head>
<title>Simple Web server</title>
<frameset rows="132,*">
<frame name="header" scrolling="no" noresize="noresize" target="main" src="head.html">
<frame name="main" src="file:///C:/web/page.html">
<noframes>
<body>
</body>
</noframes>
</frameset>
</body>
</html>
but when i run web server it loads index.html but not from c:\web folder as this index.html is a wab page should open page.html file from c:\web folder which is stored in c drive but its not opening but if i open \My Project\CD_Root\AutoPlay\Docs\index.html then it works fine i mean then it open but if i run web server and open home page its just blank just want to know what i m doing wrong here any idea?
hey there don't have it as a full .exe make it to a hard drive folder build
then make a new folder in the project and name it web server or root or htdocs what ever you fansy them to install it use the installer from indigo or a 3ed party and make a shourt cut to the c drive can call it web if you want simple access to it or even add the cut to the start menu.
if you would like any help with this please tell me and i till see what i can do
PM me to get my email adress thanks
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.