
This topic Develop Python App with Authentication and Authorization in Cloud Foundry will guide you through creating a Python application, setting up authentication checks and authorization checks in Cloud Foundry (for ease of reading “CF).
Open Cloud Platform Cockpit, navigate to your subaccount, find the corresponding API Endpoint
:
Log on to Cloud Foundry with the API Endpoint
you got by executing the following command:
cf login -a <api-endpoint>
Email
and Password
which are consistent with your Cockpit's.org
and space
.Create a new directory named python-with-xsuaa
.
Create a manifest.yml
file under the python-with-xsuaa
directory with the following content:
---
applications:
- name: myapp
host: <host>
path: .
domain: <custom-domain>
memory: 128M
command: python server.py
---
applications:
- name: myapp
host: myapp-ixxxxxx
path: .
domain: apps.sap-samples.scpcloud.top
memory: 128M
command: python server.py
runtime.txt
file, for example:python-3.7.x
requirements.txt
file with the following content:Flask
server.py
file, which will contain the following application logic:import os
from flask import Flask
app = Flask(__name__)
port = int(os.environ.get('PORT', 3000))
@app.route('/')
def hello():
return "Hello World"
if __name__ == '__main__':
app.run(host='0.0.0.0', port=port)
In case you will get problem of network in China when downloading dependencies during the process of deploying, you'd better deploy applications as self-contained, which means carry all of their dependencies so that the staging process does not require any network calls.
The Python buildpack provides a mechanism for that – applications can vendor their dependencies by creating a vendor folder in their root directory and execute the following command to download dependencies in it:
pip download -d vendor -r requirements.txt --platform manylinux1_x86_64 --only-binary=:all:
Execute the following CF command in the root of python-with-xsuaa
directory:
cf push
manifest.yml
is located.cf logs myapp --recent
When the staging and deployment steps are complete, you can check the state and URL of your application through Cockpit or CF command:
cf apps
Hello World
.This blog post shared how to create and deploy Python app onto SAP Cloud Platform Alibaba Cloud.
The most important point varies from Alibaba Cloud to Public Cloud is application domain. On the SAP Public Cloud, like AWS, Azure, etc, they will provide a public shared domain to developers. However, this kind of shared domain is not supported due to compliance in China, so in order to deploy apps onto Alibaba Cloud, developers should create a custom domain by themselves. More details on how to get your own custom domain can be found here: Use custom domain in SAP Cloud Platform on Alibaba Cloud
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
24 | |
23 | |
22 | |
14 | |
12 | |
10 | |
9 | |
7 | |
7 | |
6 |