WSGI Support Introduction

Context
The Web Server Gateway Interface (WSGI) is a simple calling convention for web servers to forward requests to web applications or frameworks written in the Python programming language. WSGI is a Python standard described in detail in PEP 3333.
🤔 Ok, great definition and what the point with iris ?
IRIS 2024.2+ has a new feature that allows you to run WSGI applications directly on IRIS. This feature is a great way to integrate IRIS with other Python frameworks and libraries.
This goes in the trend of Python first experience, where you can use Python to interact with IRIS, and now you can also run Python applications directly on IRIS.
How to use it
To instantiate a WSGI application on IRIS, you need to configure it in the Security->Applications->Web Applications section of the IRIS Management Portal.
Simple flask example:
File called app.py in /irisdev/app/community directory:
from flask import Flask
app = Flask(__name__)
@app.route('/')
def hello_world():
return 'Hello, World!'
UI Configuration

In this section, you can configure the WSGI application by providing :
Aplication Name
this corresponds of the file name of the WSGI application
ex:
app.pybut without the.pyextension :appCallable Name
the callable function that will be called by the WSGI server
ex:
appcorresponds to theappvariable in theapp.pyfileapp = Flask(__name__)
WSGI App directory
- the path where the WSGI application is located
- ex:
/irisdev/app/community
Python Protocol Type
- it can be
wsgiorasgiwsgiis the default value and the one used in this exampleasgiis for asynchronous applications- we support
asgisyncrhonously for now with thea2wsgiadapter
- we support
- it can be
DEBUG
- if checked, the WSGI application will run in debug mode
- this is useful for development purposes as any changes to the WSGI application will be automatically reloaded
- if checked, the WSGI application will run in debug mode
CPF Merge
You can also configure the WSGI application using CPF. Here is an example of the configuration:
[Actions]
CreateApplication:Name=/flask,NameSpace=IRISAPP,WSGIAppLocation=/irisdev/app/community/,WSGIAppName=app,WSGICallable=app,Type=2,DispatchClass=%SYS.Python.WSGI,MatchRoles=:%ALL,WSGIDebug=0,WSGIType=0
Log Files
The WSGI application logs are stored in the WSGI.log file located in the mgr directory of the instance.
Examples
Here are some examples of WSGI applications that you can run on IRIS, they aim to show how to run different Python frameworks on IRIS.
Basically, the use case will be the same for all the frameworks:
Endpoints
/iris- Returns a JSON object with the top 10 classes present in the IRISAPP namespace./interop- A ping endpoint to test the interoperability framework of IRIS./posts- A simple CRUD endpoint for a Post object./comments- A simple CRUD endpoint for a Comment object.
Object Model
Post object:
- id
- title
- content
Comment object:
- id
- post_id (foreign key to Post)
- content
Flask
- Github: iris-flask-template
- Article: running-flask-applications-iris
Django
- Github: iris-django-template
- Article: running-django-applications-iris
FastAPI
- Github: iris-fastapi-template
- Article: running-fastapi-applications-iris
Limitations
- The ASGI is supported synchronously for now with the
a2wsgiadapter. tornadoapplications ( jupyter, streamlit, .. ) are not supported as they are not WSGI compliant.