Devanand J
Devanand J

Reputation: 74

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"

now i have this original.exe on the same folder, i just want to update it with uuid which is fine and working , how do i make this available to download when some one does a get request. new to falcon

Upvotes: 2

Views: 1155

Answers (1)

Devanand J
Devanand J

Reputation: 74

I got it thanks

   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

if in case anybody needs it

Upvotes: 1

Related Questions