Skip to Content

Hi All,

I am writing this blog to describe some easy steps to deploy a Python based REST API( Bottle / Flask ) application on the SAP cloud foundry environment.

The current python application is a knapsack optimization problem solver created on Python using Bottle server and Google OR-tools.

Account setup Steps:

  1. You need to have an SCP neo trial account or a US – EAST (VA ) AWS account or a US West (CA) running on Azure in order to try SAP Cloud foundry.
  2. Once that is done, follow the steps 4 to 6 on the tutorial here provided by SAP which help you with basic account setup.

Application structuring and deployment:

  1. The basic structure of a Python application on the SAP Cloud foundry should be as below, can also be referred at my GIT( https://github.com/rafiqhasan/SAPCFKnapsack/tree/master/KnapSack )
    1. Procfile: File which contains Cloud foundry start command.
    2. requirements.txt: File which contains the names of external python libraries needed for this application.
    3. runtime.txt: Specifies python version to be installed for this application
  2. Once you have the application structured , start cmd on your windows based system( try similar command on linux / mac)

  • CD to the project folder on your system, ex:
CD C:\Users\hrafiq\Documents\project1_python
  • To push the application to the cloud foundry environment, simply use the command:
cf push myappname
  • where “myappname” can be any name that you want

After the application is deployed, you will get the output as below on the CMD console

The URL can be seen here which can then be tried on the web-browser or via postman tools to check if you application is working:

The application details can also be seen on your SAP Cloud platform account:

 

API Testing:

Thanks,

Hasan

To report this post you need to login first.

Be the first to leave a comment

You must be Logged on to comment or reply to a post.

Leave a Reply