falcon python to resp setup file


class Newuser(object):
    def on_get(self,req,resp):
        """
        :param req: With request reads Original.exe and append the data with "echo.CUSTDATA:uuid.uuid4()"
        :param resp: with response user will be able to download packed Setup.exe
        :return: Setup.exe with CUSTDATA:uuid.uuid4() at the end of the file.
        """
        print("requests")
        import uuid
        uui = uuid.uuid4()
        self.storage.add_user_uuid(uui,"000")
        with open("original.exe",'r') as f:
            Original_exe = f.read()
            Original_exe+=('echo.CUSTDATA:{}'.format(str(uui)))
        with open("Setup.exe",'w') as g:
            g.write(Original_exe)
        #resp.set_header("Content-Disposition", "attachment; filename="%s"" % Original_exe)
        resp.data = "Setup.exe"

现在我有这个原件.exe 在同一个文件夹中,我只想用 UUID 更新它,这很好而且可以工作,当有人发出 get 请求时,我如何使其可供下载。 猎鹰新手

我明白了,谢谢

   with open("original.exe",'r') as f:
        Original_exe = f.read()
        Original_exe+=('echo.CUSTDATA:{}'.format(str(uui)))
    Original = "Setup.exe"
    resp.set_header("Content-Disposition", "attachment; filename="%s"" % Original)
    resp.data = Original_exe
    resp.status = falcon.HTTP_200

如果有人需要它

相关内容

  • 没有找到相关文章

最新更新