Mercurial Hosting > luan
comparison src/luan/modules/http/serve.luan @ 1689:af22d6c120e4
improve http/serve.luan
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Sun, 12 Jun 2022 18:48:01 -0600 |
parents | 5eb985d1411f |
children | a4b232aa0554 |
comparison
equal
deleted
inserted
replaced
1688:5eb985d1411f | 1689:af22d6c120e4 |
---|---|
3 local Io = require "luan:Io.luan" | 3 local Io = require "luan:Io.luan" |
4 local Server = require "luan:http/Server.luan" | 4 local Server = require "luan:http/Server.luan" |
5 local String = require "luan:String.luan" | 5 local String = require "luan:String.luan" |
6 local to_number = String.to_number or error() | 6 local to_number = String.to_number or error() |
7 | 7 |
8 local count = #{...} | 8 local dir, port, extra = ... |
9 | 9 |
10 if count < 1 or count > 2 then | 10 if dir==nil or extra~=nil then |
11 Io.stderr.write "usage: luan luan:http/serve.luan dir port\n" | 11 Io.stderr.write "usage: luan luan:http/serve.luan dir [port]\n" |
12 return | 12 return |
13 end | 13 end |
14 | 14 |
15 Server.serve({...}[1],to_number({...}[2])) | 15 if port ~= nil then |
16 port = to_number(port) or error "port must be an integer" | |
17 end | |
18 | |
19 Server.serve(dir,port) |