In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces "how to use lua code to achieve a blog system". In daily operation, I believe many people have doubts about how to use lua code to achieve a blog system. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful to answer the doubts of "how to use lua code to achieve a blog system". Next, please follow the editor to study!
EventServer is a libevent-based server framework, which can be applied to web development and game server development. Https://www.lua-web.com based on the EventServer development of the lua blog framework, easy to write blog, save a variety of reprint, news gathering and editing, etc., a total of more than 900lines of code, a blog of the add, delete, change and search function; registration, audit function, login and other functions; Baidu ueditor editor interface to upload pictures, download, etc.
Like other luajit frameworks, it is easy to use, easy to deploy, easy to maintain, superior performance, and can use a variety of interfaces.
In addition, it is also compatible with various openresty libraries, especially socket-based lua libraries, such as redis,smtp,luasql, etc.
The biggest difference between this framework and other frameworks is that the synchronous blocking interface can be changed to synchronous non-blocking interface without modifying the interface.
The data SQL operation part of the interface is synchronous blocking, which is delegated to other threads through ExecuteSQL, and the result is returned after processing.
-- Log in to local function http_blog_login (req) local buffer = evhttp_get_input_buffers (req) local obj = json.decode (buffer)-- local context = {title=obj.title, doc=obj.doc} print ('http_blog_login***' Json.encode (obj) local sql = [[SELECT * FROM blogs.accounts where account=']].. Escape_sql (obj.account). [' ] local ret,rows=ExecuteSQL (THREADID_SQL, sql,true) if not ret then print ('http_blog_postxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', rows) return end if # rows==0 then print (' http_blog_modify***' Res) HttpResponeError (req, 1000, GetUtf8ByGBK ('account not registered') return end if rows [1] .loginpassword ~ = obj.password then HttpResponeError (req, 1001, GetUtf8ByGBK ('password error') return end if rows [1] .state = ='0' then HttpResponeError (req, 1002) GetUtf8ByGBK ('account not activated') return end HttpRespone (req, function (req) local time= os.time () + 60 / 60 / 24 local token= md5.sumhexa (rows [1] .userid.. magic _ CODE..time) local cookies = {userid=rows [1] .UserID, logintime=time, token=token}-'userid='..rows [1] .UserID..' '..' logintime='..time..' Token='..token local base64 = ZZBase64.encode (json.encode (cookies)) local res = json.encode ({errcode=0, errmsg=GetUtf8ByGBK ('login successful'), cookie='login='..base64}) print ('http_blog_login***' Res) evhttp_add_header (req, 'Content-Type', "text/json") evhttp_send_reply (req,200,'ok', res) end) end here The study on "how to implement a blog system with lua code" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.