服务端程序:

import tornado.web
import os

IMG_LIST=[]

class IndexHandler(tornado.web.RequestHandler):
    def get(self):

        self.render('index.html',list_img=IMG_LIST)

    def post(self, *args, **kwargs):
        name=self.get_argument('name')
        pwd=self.get_argument('pwd')
        #fn=self.get_argument('img')
        file_meta=self.request.files['img']
        for meta in file_meta:
            file_name=meta['filename']
            file_path=os.path.join('img',file_name);
            IMG_LIST.append(file_path)
            with open(os.path.join('static',file_path),"wb") as fp:
                fp.write(meta['body'])

        self.write('{"status":1,"message":"mmm"}')

settings ={
    'template_path':'views',
    'static_path':'static',
    'static_url_path':'sss'
}

application = tornado.web.Application([
    (r"/index",IndexHandler),
],**settings)


if __name__=="__main__":
    application.listen(8080)
    tornado.ioloop.IOLoop.instance().start()
View Code

相关文章:

  • 2022-03-07
  • 2021-09-25
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-07
猜你喜欢
  • 2022-02-08
  • 2021-12-18
  • 2021-11-28
  • 2021-10-18
  • 2021-12-07
  • 2022-02-08
相关资源
相似解决方案