Socket Debuggerを使ってみる! ポート:9!簡単なWeb Server [NETWORK]
SocketDebugger
こことか、 https://www.udom.co.jp/sdg/
こことか、 http://sdg.ex-group.jp/lua.html
をまず見てね!
前回のスクリプトがイマイチだったので、method GETのスクリプトをまず改造してみる。
今回はファイルパスを検索するのに連想配列を使う。ファイルの追加は容易になると思う。
※ もう少し上手く書ける気がする。修行が足らん、、、
※ お役立ちリンク
https://qiita.com/peg/items/c472f7a7d9fcca1b5cb7
https://symfoware.blog.fc2.com/blog-entry-455.html
※ 文字列で処理した方がお得なのか?、テーブルで処理した方がお得なのか?、、、悩みますな。
こことか、 https://www.udom.co.jp/sdg/
こことか、 http://sdg.ex-group.jp/lua.html
をまず見てね!
前回のスクリプトがイマイチだったので、method GETのスクリプトをまず改造してみる。
今回はファイルパスを検索するのに連想配列を使う。ファイルの追加は容易になると思う。
--------------------------------------------- -- method get --------------------------------------------- function methodGet( url, ver ) local file = {} local methodTbl = { { url = "/", path = "D:\\temp\\index.html" }, { url = "/index.html", path = "D:\\temp\\index.html" }, { url = "/index.htm", path = "D:\\temp\\index.html" }, } for i = 1, #methodTbl do local urlStr = CharFromTbl( url ) -- local verStr = CharFromTbl( ver ) if strCmp( urlStr, methodTbl[i].url ) == 0 then file = FileRead( methodTbl[i].path ) return file end end return nil end --------------------------------------------- -- compare string A and string B. --------------------------------------------- function strCmp( stringA, stringB ) local strLen = string.len( stringA ) if strLen ~= string.len( stringB ) then return -1 end for i = 1, strLen do if string.byte( stringA, i ) ~= string.byte( stringB, i ) then return -1 end end return 0 end
※ もう少し上手く書ける気がする。修行が足らん、、、
※ お役立ちリンク
https://qiita.com/peg/items/c472f7a7d9fcca1b5cb7
https://symfoware.blog.fc2.com/blog-entry-455.html
※ 文字列で処理した方がお得なのか?、テーブルで処理した方がお得なのか?、、、悩みますな。
M5Stick ミニ開発キットESP32 1.3'OLEDオプションのブザーIRトランスミッタMpu9250
- 出版社/メーカー: M5Stack
- メディア:
2019-07-08 09:43
nice!(0)
コメント(0)
コメント 0