---
title: Host your Python application on IBMi
description: When creating an app, you need a host to deploy it. We share with you how we deployed our Python application on our IBMi power system.
image: https://blog.easi.net/hubfs/Host%20your%20Python%20application%20on%20IBMi-header-en.jpg
---

[![Home](https://blog.easi.net/hubfs/easi-logo.svg)](https://easi.net)

 Hit enter to search

- [All](https://blog.easi.net/en)
- [Adfinity](https://blog.easi.net/en/tag/adfinity)
- [Cloud](https://blog.easi.net/en/tag/cloud)
- [Easi](https://blog.easi.net/en/tag/easi)
- [Microsoft](https://blog.easi.net/en/tag/microsoft)
- [Rooftop](https://blog.easi.net/en/tag/rooftop)
- [Security](https://blog.easi.net/en/tag/security)
- [SmartSales](https://blog.easi.net/en/tag/smartsales)
- [Spoom](https://blog.easi.net/en/tag/spoom)

[Go back to the blog](https://blog.easi.net/en?hsLang=en)

# [Host your Python application on IBMi](https://blog.easi.net/en/host-your-python-application-on-ibmi)

[![Author Avatar](https://blog.easi.net/hubfs/Images/EASI/Copy%20of%20HR%20-%20NEW%20EMPLOYEE%20PICTURE%20%20(2).png) Pinar Bedel Business Consultant](https://blog.easi.net/en/author/pinar-bedel)

We all start with building our applications on our own desktop. We start making a new project or build an idea from scratch on our own local host. But what when it is fully finished or ready enough to share with the rest of the world? A production environment is necessary for this. As you might know, or maybe hear for the first time, an application deployment is needed to run your app. In this blog post, we share with you how we deployed our Python application on our IBMi power system.

## Project setup

For our project setup, we created the products\_module, and the users\_module to separate these two from each other. Modules are used when you import statements such as import Flask. These created modules contain a model and a Controller. The Model interacts with the database and the Controller interacts with the model and fetches the asked information through triggers or events.

![Picture 1-2](https://blog.easi.net/hs-fs/hubfs/Picture%201-2.png?width=199&name=Picture%201-2.png)

The \_\_init\_\_.py file contains the import of packages and the configuration of the project, our example.

Used packages

Flask: https://github.com/flask-api/flask-api

Flask-restful: [https://github.com/flask-restful/flask-restful](https://github.com/flask-restful/flask-restful)

Flask-SqlAlchemy: https://github.com/pallets-eco/flask-sqlalchemy

SqlAlchemy-ibmi: https://github.com/IBM/sqlalchemy-ibmi

## Connecting with DB2

For the connection with our db2 database, we used the package “Flask-SQLAlchemy”. This package can be easily installed and configured. After setting up the Flask application, the connection to the database can be configured with SQLAlchemy. This package is managed by IBM, which provides that this package will stay up to date. The package is also open source, which makes expansions possible by the community.

In our demo, we added the configuration through a separate config file. In the picture below, you can see the import of Flask and SQLAlchemy and define the first steps of the connection.

![picture 2](https://blog.easi.net/hs-fs/hubfs/picture%202.png?width=264&name=picture%202.png)

The config file is the next step, this defines which database schema you use, your connection host, and the connection user.

![picture 3](https://blog.easi.net/hs-fs/hubfs/picture%203.png?width=602&name=picture%203.png)

## Deployment with FastCGI

The first step of deploying our application is using FastCGI, this is a deployment option for Python. To deploy your Python application with FastCGI, you need to create a WSGI server that will run your application. This package can be easily imported and used as following:

![picture 4](https://blog.easi.net/hs-fs/hubfs/picture%204.png?width=329&name=picture%204.png)

## Configuring an HTTP Server

For the last step of the real deployment of our Python application, we created an HTTP Server on our IBMi system. Creating the HTTP Server is the easy step, the next step is adding the configuration. With the IBM Web Administration for I platform aka HTTP Admin, it is easy to configure the httpd configuration file. The first step is adding the FastCGI module to handle your Python script. Afterwards, the document root and the directory of your Python application must be added to the configuration file as well, this is the location of your application on your system.

Here is an example of the httpd.conf file:

![picture 5](https://blog.easi.net/hs-fs/hubfs/picture%205.png?width=395&name=picture%205.png)

![picture 5 bis](https://blog.easi.net/hs-fs/hubfs/picture%205%20bis.png?width=223&name=picture%205%20bis.png)

## Demo of our small Python application

For this proof of concept of our Python application named “pythonflask”, we created an API application that returns raw JSON data. Two routes were created that call our model, which connects to our database to get the data from the needed table. In the controller, we define the resource fields and then get the data we need, this can be all the data from that table or just one product by product name or ID. This will return the needed info and send it back to the interface.

Our two route calls contain all the data of our products, and the users.

![picture 6](https://blog.easi.net/hs-fs/hubfs/picture%206.png?width=500&name=picture%206.png)

Below is an example of the controller to retrieve the product data, the first returns the one product that identifies with the requested product ID, whereas the second one return all the product data from the table.

![picture 7](https://blog.easi.net/hs-fs/hubfs/picture%207.png?width=421&name=picture%207.png)

 

[![M365 Discovery Track - Hubspot Banner - EN](https://no-cache.hubspot.com/cta/default/473564/interactive-156863034745.png)](https://blog.easi.net/hs/cta/wi/redirect?encryptedPayload=AVxigLLL9OtdGTh4dGGymog8i6ZLXsDfZt%2FZy6t35XRhJbI8RHH%2B4P6a%2BA9knPX1aRIpeSVSQxjSxlfYFQsOvNVpYtCXXAimiI63BXHmYcncotremjSMjlM%2BtYecMQVr%2F0TOe3%2BdsABI%2BpkpoDM7CfTFBwz6oI%2Fi2jz6BLryXzjjrb1z%2BHZfhP%2Bl13RYgVP3HEESOhdJElsEroI%2B&webInteractiveContentId=156863034745&portalId=473564&hsLang=en)

 

[IBM Power](https://blog.easi.net/en/topic/ibm-power?hsLang=en)

## Current job openings

We are constantly looking for new colleagues!

If you share our values and you're looking for a challenging job in Belgium's Best Workplace, visit our website.

[Apply now](https://easi.net/en/jobs)

### Get our top stories in your inbox every month

## Follow us

[![Share on Facebook](https://static.hubspot.com/final/img/common/icons/social/facebook-24x24.png)](http://www.facebook.com/easi.net) [![Share on LinkedIn](https://static.hubspot.com/final/img/common/icons/social/linkedin-24x24.png)](https://www.linkedin.com/company/easi) [![Share on Twitter](https://static.hubspot.com/final/img/common/icons/social/twitter-24x24.png)](https://twitter.com/easi_net)

## Recent posts

![Why OT Cybersecurity Is No Longer Just an IT Problem](https://blog.easi.net/hubfs/Agoria%20Whitepaper%20blog%201%20-%20EN%20%281%29.png)

### [Why OT Cybersecurity Is No Longer Just an IT Problem](https://blog.easi.net/en/solutions/security/ot-cybersecurity-is-no-longer-just-an-it-problem?hsLang=en)

01/06/2022

![Microsoft 365 Copilot Cowork: From AI Assistant to AI Coworker](https://blog.easi.net/hubfs/Copilot%20Cowork%20is%20now%20available%20-EN%20%286%29-1.png)

### [Microsoft 365 Copilot Cowork: From AI Assistant to AI Coworker](https://blog.easi.net/en/solutions/microsoft/copilot-cowork-is-now-available?hsLang=en)

01/06/2022

![Microsoft 365 Archive goes file-level: how to cut SharePoint storage costs from July 2026](https://blog.easi.net/hubfs/Copilot%20Cowork%20is%20now%20available%20-EN%20%283%29.png)

### [Microsoft 365 Archive goes file-level: how to cut SharePoint storage costs from July 2026](https://blog.easi.net/en/solutions/microsoft/m365-archive-file-level?hsLang=en)

01/06/2022

## Share this article

[![Share on Facebook](https://static.hubspot.com/final/img/common/icons/social/facebook-24x24.png)](http://www.facebook.com/share.php?u=https%3A%2F%2Fblog.easi.net%2Fen%2Fhost-your-python-application-on-ibmi%3Futm_medium%3Dsocial%26utm_source%3Dfacebook) [![Share on LinkedIn](https://static.hubspot.com/final/img/common/icons/social/linkedin-24x24.png)](http://www.linkedin.com/shareArticle?mini=true&url=https%3A%2F%2Fblog.easi.net%2Fen%2Fhost-your-python-application-on-ibmi%3Futm_medium%3Dsocial%26utm_source%3Dlinkedin) [![Share on Twitter](https://static.hubspot.com/final/img/common/icons/social/twitter-24x24.png)](https://twitter.com/intent/tweet?original_referer=https%3A%2F%2Fblog.easi.net%2Fen%2Fhost-your-python-application-on-ibmi%3Futm_medium%3Dsocial%26utm_source%3Dtwitter&url=https%3A%2F%2Fblog.easi.net%2Fen%2Fhost-your-python-application-on-ibmi%3Futm_medium%3Dsocial%26utm_source%3Dtwitter&source=tweetbutton&text=Host%20your%20Python%20application%20on%20IBMi)

### Never miss our stories

## Related articles

[See all blog articles](https://blog.easi.net/en/tag/ibm-power)

![The 3 most common mistakes made on IBM i](https://blog.easi.net/hubfs/Images/Infrastructure/mistakesibm.jpg)

### [The 3 most common mistakes made on IBM i](https://blog.easi.net/en/services/ibm-power-systems/the-3-most-common-mistakes-made-on-ibm-i?hsLang=en)

These are 3 lifesavers when you are talking about keeping your IBM i infrastructure up to date.

[Read more](https://blog.easi.net/en/services/ibm-power-systems/the-3-most-common-mistakes-made-on-ibm-i?hsLang=en)

![Host your Python application on IBMi](https://blog.easi.net/hubfs/Host%20your%20Python%20application%20on%20IBMi-header-en.jpg)

### [Host your Python application on IBMi](https://blog.easi.net/en/host-your-python-application-on-ibmi)

We all start with building our applications on our own desktop. We start making a new project or...

[Read more](https://blog.easi.net/en/host-your-python-application-on-ibmi)

![Easi at Common Europe Congress 2022](https://blog.easi.net/hubfs/EN-Easi-op-Common-Europe-congress-2022.jpg)

### [Easi at Common Europe Congress 2022](https://blog.easi.net/en/easi-op-common-europe-congress-2022?hsLang=en)

On the 13th of June, IBM i users from all over Europe will meet for the Common Europe Congress,...

[Read more](https://blog.easi.net/en/easi-op-common-europe-congress-2022?hsLang=en)

- [Solutions](https://www.easi.net) 
    - [AAA Financials](https://www.easi.net/en/solutions/aaa-financials)
    - [Adfinity](https://adfinity.easi.net)
    - [Cloud2be](https://www.easi.net/en/solutions/managed-cloud)
    - [Rooftop](https://www.easi.net/en/solutions/rooftop)
    - [Security](https://www.easi.net/en/solutions/security)
    - [SmartSales](https://www.easi.net/en/solutions/smartsales)
    - [SmartDrive](https://smartdrive.easi.net)
    - [SmartShare](https://smartshare.easi.net)
    - [Synchro Production](https://www.easi.net/en/solutions/synchro-production)
- [Services](https://www.easi.net/en/services) 
    - [Mobile Development](https://www.easi.net/en/services/mobile-development)
    - [Software development](https://www.easi.net/en/services/application-development)
    - [Managed Services](https://www.easi.net/en/services/managed-services)
    - [On Premise infrastructure](https://www.easi.net/en/services/it-infrastructure-projects)
    - [Cosourcing](https://www.easi.net/en/services/co-sourcing)
    - [End user support](https://www.easi.net/en/services/end-user-support)
- [Company](https://www.easi.net) 
    - [About EASI](https://www.easi.net/en/about-easi)
    - [Jobs](https://www.easi.net/en/jobs)
    - [Blog](https://blog.easi.net)
    - [Press](https://www.easi.net/en/press)
    - [Customer stories](https://www.easi.net/en/customer-stories-references)
    - [Trainings](https://www.easi.net/en/trainings)
    - [Events](https://www.easi.net/en/events)
    - [Customer support](https://www.easi.net/en/customer-support)
    - [Legal](https://www.easi.net/en/about/legal/website-privacy-policy)
- Useful links 
    - [Microsoft](https://www.easi.net/en/services/microsoft)
    - [IBM Power Systems](https://www.easi.net/en/services/ibm-power-systems)
    - [IBM Notes](https://www.easi.net/en/services/ibm-notes)
    - [EASI Jump](https://www.easi.net/en/easi-jump)

- [English](https://blog.easi.net/en/host-your-python-application-on-ibmi)
- [Français - Belgique](https://blog.easi.net/fr/host-your-python-application-on-ibmi)
- [Nederlands - België](https://blog.easi.net/nl/host-your-python-application-on-ibmi)

- [Privacy](https://www.easi.net/about/legal/website-privacy-policy)
- [info@easi.net](mailto:info@easi.net)
- [+32 67 28 10 00](tel:+3216313000)
- [Contact](https://www.easi.net/en/contact)

- <https://www.linkedin.com/company/easi>
- <https://twitter.com/easi_net>
- <https://www.facebook.com/easi.net>
- <https://www.instagram.com/easi_net/>
- <https://vimeo.com/easinet>
- <https://www.youtube.com/user/EASIMedias>