ZNZNCOOP

WebServ

May 21st, 2014
198
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. path='/web/'
  2. os.loadAPI('ip')
  3. if not ip.open() then
  4.   print('No modem found')
  5.   return
  6. end
  7.  
  8. if not ip.getIP() then
  9.   print('Can not register in Craftnet')
  10.   return
  11. end
  12.  
  13. while true do
  14.   m,i=ip.receive()
  15.   if i then
  16.     if m=='' then m='index' end
  17.     print(i,' ',m)
  18.     file=fs.open(path..m,'r')
  19.     if not file then file=fs.open(path..'404','r') end
  20.     if file then
  21.       text=file.readAll() file.close()
  22.     else
  23.       text='Can not open file'
  24.     end
  25.     ip.send(i,text)
  26.   end
  27. end
RAW Paste Data