python用web.py 搭建一个简单文件读取服务
2019-06-04 本文已影响0人
Rollan
import web
import os
urls=(
'/readFile/(.*)','readFile'
)
app = web.application(urls,globals())
class readFile:
def GET(self,path):
file = os.open(path,os.O_RDONLY)
fSize = os.path.getsize(path)
fileValue = os.read(file,fSize)
os.close(file)
return fileValue
if __name__ == '__main__':
app.run()