Commits

zhangchunlin  committed bb488f1

support file share now

  • Participants
  • Parent commits 767617e

Comments (0)

Files changed (1)

File apps/autobuild/views.py

 from uliweb import expose,settings,request,application
 from uliweb.utils.filedown import filedown
 from uliweb.utils.textconvert import text2html
+from werkzeug.exceptions import NotFound 
 
 @expose('/')
 def index():
         if cache.has_key(fp):
             return cache[fp]
         else:
-            f = open(fp)
-            f.seek(0,os.SEEK_END)
-            size = f.tell()
-            f.close()
+            size = os.path.getsize(fp)
             cache[fp]= size
             cache_touched = True
             return size
     
     return {"clform":form,"changes":changes}
 
-@expose('/updateip.py',static=True)
-def robots():
-    return filedown(request.environ, application.get_file('updateip.py'))
-
 def get_after_time(year,month,day,hour=0,minute=0,second=0):
     return datetime.datetime(int(year),int(month),int(day),int(hour),int(minute),int(second))
 
                     latest_result += "\n"
             break
     return latest_result
+
+
+#file share
+
+@expose('/updateip.py',static=True)
+def updateip():
+    return filedown(request.environ, application.get_file('updateip.py'))
+
+@expose('/s/<fn>',static=True)
+def sfiles(fn):
+    files = settings.SFILES.FILES
+    if (files!=None) and files.has_key(fn):
+        fp = files[fn]
+        if os.path.exists(fp):
+            return filedown(request.environ, fp)
+    raise NotFound