2
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"

现在我在同一个文件夹中有这个 original.exe,我只想用 uuid 更新它,这很好并且可以工作,当有人提出获取请求时,我如何使它可供下载。猎鹰新手

4

1 回答 1

1

我知道了谢谢

   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

如果有人需要的话

于 2017-04-05T12:32:06.247 回答