Skip to content

I created this mainly to see if I could. Never integrated another language before so this was an interesting little toy project for the holidays when I had some time.

License

Notifications You must be signed in to change notification settings

PetrusJPrinsloo/lua-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

lua-server

Build

Small experiment of mine over the holiday to make a webserver with lua. This is by no means meant to be a production system so please don't use it as such.

app/routes.lua file starts a server like this:

local m = require("modules")

routes = {
    index = "/",
    user = "/user"
}

m.startServer('8080')

Then for the /user route create a file app/user.lua and that file will be executed when that endpoint is hit:

local m = require("services")

local b = "<h1>Hello There</h1>" ..
        "<p>here's a paragraph</p>" ..
        "<button>Button</button>"

response.body = b

The response.body can be set to any string and this will be sent to the browser as html.

If data is sent to form using POST or PUT methods, the data is placed in a global table called POST_DATA.

About

I created this mainly to see if I could. Never integrated another language before so this was an interesting little toy project for the holidays when I had some time.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published