diff --git a/README.md b/README.md index 4c46c84..068200a 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ Send `who`, `why` and `what` with desired text as GET parameters to `/v1/excuse` Example: ``` -https://xzmc1m2dgb.execute-api.eu-central-1.amazonaws.com/prod/v1/excuse/?who=serverless%20dev&why=my%20function%20is%20uploading%20to%20aws&what=uploading +https://tyiz03gx7h.execute-api.eu-central-1.amazonaws.com/prod/v1/excuse/?who=0&why=my%20code%20is%20compiling&what=compiling ``` You get the simplest api response in the world: @@ -30,7 +30,7 @@ You get the simplest api response in the world: ``` { data: { - image_url: "http://localhost:8000/media/5345525645524c45535320444556-4d592046554e4354494f4e2049532055504c4f4144494e4720544f20415753-55504c4f4144494e47.png" + image_url: "https://tyiz03gx7h.execute-api.eu-central-1.amazonaws.com/media/30-4d5920434f444520495320434f4d50494c494e47-434f4d50494c494e47.png" } } ``` diff --git a/app.py b/app.py index 53258d9..fdad52b 100644 --- a/app.py +++ b/app.py @@ -26,8 +26,8 @@ dir_path = os.path.dirname(os.path.realpath(__file__)) @hug.get( - versions=1, - examples='who=programmer&why=my%code%20is%20compiling&what=compiling' + versions=1 + # examples='who=programmer&why=my%20code%20is%20compiling&what=compiling' TODO ) def excuse(request, response, who: hug.types.text='', why: hug.types.text='', what: hug.types.text='') -> dict: """ @@ -64,9 +64,11 @@ def excuse(request, response, who: hug.types.text='', why: hug.types.text='', wh if isinstance(data, Image.Image): who_hex, why_hex, what_hex = _encode_hex(who, why, what) - image_url = '{scheme}://{domain}/media/{who}-{why}-{what}.png'.format( + deploy_stage = os.environ.get('DEPLOY_STAGE') + image_url = '{scheme}://{domain}/{deploy_stage}media/{who}-{why}-{what}.png'.format( scheme=request.scheme, domain=request.netloc, + deploy_stage='{}/'.format(deploy_stage) if deploy_stage else '', who=who_hex, why=why_hex, what=what_hex @@ -86,8 +88,8 @@ def excuse(request, response, who: hug.types.text='', why: hug.types.text='', wh @hug.local() @hug.get( '/media/{who_hex}-{why_hex}-{what_hex}.png', - output=hug.output_format.png_image, - examples='/' + output=hug.output_format.png_image + # examples='/' TODO ) def img(who_hex: hug.types.text, why_hex: hug.types.text, what_hex: hug.types.text): """ diff --git a/zappa_settings.json b/zappa_settings.json index b73eb0d..208492c 100644 --- a/zappa_settings.json +++ b/zappa_settings.json @@ -3,10 +3,16 @@ "app_function": "app.__hug_wsgi__", "aws_region": "eu-central-1", "profile_name": "mislavcimpersak", - "s3_bucket": "excuse-generator" + "s3_bucket": "excuse-generator", + "aws_environment_variables": { + "DEPLOY_STAGE": "prod" + } }, "dev": { "extends": "prod", - "debug": true + "debug": true, + "aws_environment_variables": { + "DEPLOY_STAGE": "dev" + } } }