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

V1
FunctionApp
|-- host.json
|-- function_1
|	|-- function.json
|	|-- __init__.py
|-- function_2
|	|-- function.json
|	|-- __init__.py
V2
FunctionApp
|-- host.json
|-- local.settings.json
|-- function_app.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")

Or, for V2 projects:

from cactus.flask import build_app_v2
app = build_app_v2("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
from cactus.route_info import parse_project

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

Or, for V2 projects:

from cactus.flask import build_blueprint
from cactus.route_info import parse_project_v2

app = flask.Flask(__name__)
b = build_blueprint("myfunctionapp", parse_project_v2("/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.4.1.tar.gz (8.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pycactus-0.4.1-py3-none-any.whl (9.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pycactus-0.4.1.tar.gz
  • Upload date:
  • Size: 8.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.12

File hashes

Hashes for pycactus-0.4.1.tar.gz
Algorithm Hash digest
SHA256 39885227fdf4eb1f44bba7750ed9a5f4f2252b780d566a6f545047767e481ca2
MD5 1181dfd8005cde6eaff2ac60fdb42ff8
BLAKE2b-256 963731060fee69b9be7c959b7f29730a2efc58f2b8035b2ae9e8b9df345bbdb3

See more details on using hashes here.

File details

Details for the file pycactus-0.4.1-py3-none-any.whl.

File metadata

  • Download URL: pycactus-0.4.1-py3-none-any.whl
  • Upload date:
  • Size: 9.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.12

File hashes

Hashes for pycactus-0.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c77738d2a70dcfa3195b51e8e05d0eaf212789414f8131e569f6d371d7524f37
MD5 1629affd7f3ce1573c91cba6cba2edd7
BLAKE2b-256 6bd1f199b962802913a71ad35603db5297799dcfb5edfec3fea41ceace5f8def

See more details on using hashes here.

Supported by

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