<form method=post enctype=multipart/form-data>
<input type=file name=file>
<input type=submit value=Upload>
</form>import boto3
@app.route('/', methods=['GET', 'POST'])
def make_prediction():
file = request.files['file']
# save image to S3
client = boto3.client('s3',
aws_access_key_id='aws_access_key_id',
aws_secret_access_key='aws_secret_access_key'
)
client.put_object(
Body=file.read(),
Bucket=S3_BUCKET_NAME,
Key=filename)
# save image locally
file.seek(0) # re-read the whole file from the start
file_path = os.path.join(app.config['UPLOAD_FOLDER'], filename)
file.save(file_path)