Skip to main content

Adapter to run an Azure Function Application with a WSGI Web Server.

Project description

Cactus

Adapter to run an Azure Function Application with a WSGI Web Server.

How it works

Given the path of a folder containing a Function App, it builds a WSGI App parsing the Function settings. The app simply calls the Function main according to the route/methods settings.

Supported Function

This software is meant to support only Function which use binding httpTrigger as input and http as output. No other binding types. This is not an Azure emulator.

Function App structure

FunctionApp
|-- host.json
|-- function_1
|	|-- function.json
|	|-- __init__.py
|-- function_2
|	|-- function.json
|	|-- __init__.py

Installing

pip install pycactus
pip install pycactus[flask] # to use Flask as web framework

How to run

Create a file "wsgi.py"
from cactus.appfactory import build_app
app = build_app("YourFunctionAppFolder")

Or, to use Flask as web framework:

from cactus.flask import build_app
app = build_app("YourFunctionAppFolder")
Run it with a WSGI Web Server
gunicorn wsgi:app
uwsgi --http localhost:7071 --module wsgi:app

Checkout the examples for more.

Using Flask blueprints

from cactus.flask import build_blueprint

app = flask.Flask(__name__)
b = build_blueprint("myfunctionapp", "/path")
app.register_blueprint(b)

Testing

This module is tested using Fir WSGI client.

# Create a virtual environment 
python3 -m venv venv
source venv/bin/activate
# Install requirements
pip install -r requirements -r test-requirements
# Run tests with coverage
python -m pytest tests --cov=cactus

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

pycactus-0.1.0.tar.gz (6.8 kB view details)

Uploaded Source

File details

Details for the file pycactus-0.1.0.tar.gz.

File metadata

  • Download URL: pycactus-0.1.0.tar.gz
  • Upload date:
  • Size: 6.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.6

File hashes

Hashes for pycactus-0.1.0.tar.gz
Algorithm Hash digest
SHA256 0d36e766800ecfd552ba4aa63b3c3f5c9dcdbf42eda664c49ffc3fc87e30916a
MD5 8704964eb87a838cb5cdb481a27bcae7
BLAKE2b-256 3025810284ea829813c47a9062ec88c52895c536a0f8a55fdea8bfbafe40f5b6

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 Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page