Skip to content

Commit

Permalink
Fix lua server for POST, update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
zpao committed Jul 9, 2015
1 parent 89fd834 commit 0eb5dbd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
15 changes: 8 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,6 @@ This is the React comment box example from [the React tutorial](http://facebook.

There are several simple server implementations included. They all serve static files from `public/` and handle requests to `comments.json` to fetch or add data. Start a server with one of the following:

### Lua

```
go get github.com/xyproto/algernon
algernon server.lua
```

### Node

```sh
Expand Down Expand Up @@ -44,4 +37,12 @@ php server.php
go run server.go
```

### Lua

```sh
go get github.com/xyproto/algernon
# or brew install algernon
algernon server.lua
```

And visit <http://localhost:3000/>. Try opening multiple tabs!
8 changes: 4 additions & 4 deletions server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ handle("/comments.json", function()
-- Handle requests
if method() == "POST" then
-- Add the form data table to the JSON document
comments:add(ToJSON(formdata()))
else
-- Return the contents of the JSON file
print(tostring(comments))
comments:add(ToJSON(formdata(), 4))
end

-- Return the contents of the JSON file
print(tostring(comments))

end)

servedir("/", "public")

0 comments on commit 0eb5dbd

Please sign in to comment.