Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
mongoose
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Ganil-acq
GANILinux
linux-service
library
mongoose
Commits
a560334f
Commit
a560334f
authored
12 years ago
by
Sergey Lyubka
Browse files
Options
Downloads
Plain Diff
Merge pull request #111 from dpsk/lua_docs
Lua docs
parents
c78fe425
cd170703
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
UserManual.md
+3
-2
3 additions, 2 deletions
UserManual.md
examples/lua/prime_numbers.lp
+42
-0
42 additions, 0 deletions
examples/lua/prime_numbers.lp
with
45 additions
and
2 deletions
UserManual.md
+
3
−
2
View file @
a560334f
...
@@ -307,8 +307,9 @@ like request method, all headers, etcetera. Please refer to
...
@@ -307,8 +307,9 @@ like request method, all headers, etcetera. Please refer to
`struct mg_request_info`
definition in
`struct mg_request_info`
definition in
[
mongoose.h
](
https://github.com/valenok/mongoose/blob/master/mongoose.h
)
[
mongoose.h
](
https://github.com/valenok/mongoose/blob/master/mongoose.h
)
to see what kind of information is present in
`request_info`
object. Also,
to see what kind of information is present in
`request_info`
object. Also,
[
page.lp
](
https://github.com/valenok/mongoose/blob/master/test/page.lp
)
[
page.lp
](
https://github.com/valenok/mongoose/blob/master/test/page.lp
)
and
contains some example code that uses
`request_info`
.
[
prime_numbers.lp
](
https://github.com/valenok/mongoose/blob/master/examples/lua/prime_numbers.lp
)
contains some example code that uses
`request_info`
and other functions(form submitting for example).
One substantial difference of mongoose's Lua Pages and PHP is that Mongoose
One substantial difference of mongoose's Lua Pages and PHP is that Mongoose
...
...
This diff is collapsed.
Click to expand it.
examples/lua/prime_numbers.lp
0 → 100644
+
42
−
0
View file @
a560334f
<?
-- Lua server pages have full control over the output, including HTTP
-- headers they send to the client. Send HTTP headers:
print('HTTP/1.0 200 OK\r\nContent-Type: text/html\r\n\r\n')
?>
<html>
<p>
Prime numbers from 0 to 100, calculated by Lua:
</p>
<?
function is_prime(n)
if n <= 0 then return false end
if n <= 2 then return true end
if (n % 2 == 0) then return false end
for i = 3, n / 2, 2 do
if (n % i == 0) then return false end
end
return true
end
for i = 1, 100 do
if is_prime(i) then print('<span>' .. i .. '</span> ') end
end
?>
<p>
Reading POST data from Lua (click submit):
</p>
<form
method=
"POST"
><input
type=
"text"
name=
"t1"
/><input
type=
"submit"
></form>
<pre>
POST data: [
<? print(read())?>
]
request method: [
<? print(request_info.request_method) ?>
]
IP/port: [
<? print(request_info.remote_ip, ':', request_info.remote_port) ?>
]
URI: [
<? print(request_info.uri) ?>
]
HTTP version [
<? print(request_info.http_version) ?>
]
HEADERS:
<?
for name, value in pairs(request_info.http_headers) do
print(name, ':', value, '\n')
end
?>
</pre>
</html>
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment