Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0eb5dbd

Browse files
committed
Fix lua server for POST, update readme
1 parent 89fd834 commit 0eb5dbd

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

README.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,6 @@ This is the React comment box example from [the React tutorial](http://facebook.
88

99
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:
1010

11-
### Lua
12-
13-
```
14-
go get github.com/xyproto/algernon
15-
algernon server.lua
16-
```
17-
1811
### Node
1912

2013
```sh
@@ -44,4 +37,12 @@ php server.php
4437
go run server.go
4538
```
4639

40+
### Lua
41+
42+
```sh
43+
go get github.com/xyproto/algernon
44+
# or brew install algernon
45+
algernon server.lua
46+
```
47+
4748
And visit <http://localhost:3000/>. Try opening multiple tabs!

server.lua

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ handle("/comments.json", function()
1717
-- Handle requests
1818
if method() == "POST" then
1919
-- Add the form data table to the JSON document
20-
comments:add(ToJSON(formdata()))
21-
else
22-
-- Return the contents of the JSON file
23-
print(tostring(comments))
20+
comments:add(ToJSON(formdata(), 4))
2421
end
2522

23+
-- Return the contents of the JSON file
24+
print(tostring(comments))
25+
2626
end)
2727

2828
servedir("/", "public")

0 commit comments

Comments
 (0)