Skip to main content

Serverless WSGI apps made easy

Project description

Build Status

codecov

Welcome to WSGIMagic!

The use of API Gateways backed by Serverless functions is currently expanding at a massive rate, however every provider has their own special way of presenting the HTTP request to the backend. This means a lot of very boring, very tedious work for us developers every time we want to use a new service. The goal of this package is to remove the barrier between the different cloud providers, and allow you to focus on wrting good old Python WSGI APIs.

The first environment that has been targeted is the combination of the AWS API Gateway ending as a proxy to AWS Lambda. Before you would need to find out how Amazon was structuring the incoming request information, and how to send that informaton back to get a proper response to the client. WSGIMagic allows you to handle everything with a basic decorator. The following example illustrates a very small example using Flask.

from flask import Flask

from wsgimagic.aws_lambda import lambda_magic

app = Flask(name)

@app.route('/hello', allowed_methods=['GET']) def hello() return 'Hello World'

@lambda_magic(app) def event_handler(event, context): pass

By using the lambda_magic decorator, the incoming API Gateway event will automatically be translated to the WSGI format and passed off to your application. For basic request handling, this is all you need to do. The lambda_magic decorator also allows you to specify additional response headers that need to be added, define the server name and port that your app will be told it is running under, and provide a custom error handler in case something goes really wrong with your requests. I will add more written documentation in the near future, however all of the functions should have decent doc strings that will provide any other available features.

Long term this package will aim to provide similar decorators for other Serverless providers who also do not pass HTTP messages along pre-translated to the WSGI format.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

wsgimagic-1.0.0.tar.gz (4.8 kB view details)

Uploaded Source

Built Distribution

wsgimagic-1.0.0-py3-none-any.whl (5.9 kB view details)

Uploaded Python 3

File details

Details for the file wsgimagic-1.0.0.tar.gz.

File metadata

  • Download URL: wsgimagic-1.0.0.tar.gz
  • Upload date:
  • Size: 4.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.6.5

File hashes

Hashes for wsgimagic-1.0.0.tar.gz
Algorithm Hash digest
SHA256 2cc611f45e34bae22a75fc9719b3b12a700e390bd8ede78d82a7e8e59acfdc9e
MD5 bc6e34f3bca85e8200bc3a5928c42956
BLAKE2b-256 c7fc727c31f218c3105c97879a877711cbc7bede8d8f4de5e56869e6542dca4d

See more details on using hashes here.

File details

Details for the file wsgimagic-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: wsgimagic-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 5.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.6.5

File hashes

Hashes for wsgimagic-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 843cfebbce54e320ed551b5dcca9df43a182558b2d23f3adba00d420ab427b1a
MD5 974607c815283ccea629bd6363a923dc
BLAKE2b-256 c79daf8598bc228b25bf60ef9a7c8fea6d24f8f5a1232b051caed21ec6f644e0

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page