def show_mb(w, h, it): wMin, hMin, itMin = 1, 1, 1 wMax, hMax, itMax = 800, 600, 1000 if (w < wMin or w > wMax) or (h < hMin or h > hMax) or (it < itMin or it > itMax): return template('error.html', w=w, h=h, it=it, wMin=wMin, wMax=wMax, hMin=hMin, hMax=hMax, itMin=itMin, itMax=itMax) else: mb.create_mb(w, h, it) return template('index.html', mb='/mb.png', w=w, h=h, it=it)
def generateToS3(bucketname): w, h, it = 512, 512, 10 mb.create_mb(w, h, it) s3 = boto3.resource('s3') bucket = s3.Bucket(bucketname) if not bucket in s3.buckets.all(): bucket.create() bucket.upload_file(IMG_NAME, IMG_NAME) imgUrl = s3.meta.client.generate_presigned_url('get_object', Params={'Bucket': bucketname, 'Key': IMG_NAME}) return template('index.html', w=w, h=h, it=it, imgUrl=imgUrl)