I am building a small server application in Flask as part of a project I am working on. Part of the functionality is the ability to upload a small file of instructions for one of the key injectors to download. Each key injector has a name (''') which corresponds to a client and the file is uploaded to the server via a POST request.
The following listing is the Flask code.
@app.route('/upload/instructions/<ducky_name>/', methods = ['POST'])
def upload_Instruction(ducky_name):
file = request.files()
path = os.getcwd() +"/files/" + ducky_name
with open(path, "w") as f:
f.write(file)
print(f)
f.close()
return "Success"
And I am using this curl command to upload the file.
curl -X POST -d @test http://127.0.0.1:5000/upload/instructions/test1
I then get a 308 redirect, and the file is not uploaded. This is the first time I've dealt with uploading files as a POST in this way, and the also the first time I've used Flask.
Thanks