OPENWRT Web Development Lua language

Source: Internet
Author: User
Tags lua

To implement the development of the Router configuration page on the router

Is the router, after the label, the management path is generally 192.168.1.1 or 192.168.0.1

To implement a set of such small projects

The project content is very small, the individual is interested, therefore took the task

Router comes with Nginx LUA support

Any web development, as long as there is a clear REQUEST,RESPONSE,MVC structure, it is easy to get started.

Front-end Reference js/jquery.idtabs.min.js

Back-end Sample code

#!/usr/bin/env lualocal JSON = require "Los.json" local util = Require "los.util"--Configuration file path wifiplacedatapath= "/etc/        Testconfig.data "--Set Local function set_placeinfo (data) Local str=" "Util.exec (' rm-rf ': Wifiplacedatapath) For k,v in pairs (data) does if k~= "Act" then Util.exec ("echo"). K..  "|" .. V.. ">>". Wifiplacedatapath) End End Ngx.print (Json.encode ({status=0})) end--read function getplaceinfo () local bw = IO.O Pen (wifiplacedatapath) Local wifidata={} if bw then local Bwraw = Bw:read ("*a") Local tabs= split ( Bwraw, "\ n") for I=1, #tabs does if Tabs[i]~=nil and tabs[i]~= ' then local subtabs=split (tabs[i            ],"|")     WIFIDATA[SUBTABS[1]]=SUBTABS[2] End END end return wifidataendlocal function Get_placeinfo () Local Wifidata=getplaceinfo () Ngx.print (Json.encode (wifidata)) end--route local function parser () Local args = Ngx.req.get _uri_args () if ToString (args. act) = = "Get" Thenget_placeinfo () ElseIf tostring (args.act) = = "Set" Thenset_placeinfo (args) endendparser () Local  function split (str, delimiter) if Str==nil or str== "or delimiter==nil thenreturn nilend local result = {} for Match In (str.. Delimiter): Gmatch ("(.-)". Delimiter) do Table.insert (result, match) end return Resultend

  

OPENWRT Web Development Lua language

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.