Get started with Python Flask Framework on IBM Bluemix
Get started with Python Flask Framework on IBM Bluemix
This work is based on Getting started with Python on Bluemix Tutorial
The tutorial will develop a Python web application based on Flask framework and deploy the app on IBM Bluemix. The app shows up a basic form which users can type their names. When hit enter the name will be added to database and can be accessed at
http://base_url/api/visitors
1. Requirement
2. Clone example code and run locally
git clone https://github.com/IBM-Bluemix/get-started-python
cd get-started-python
- Rename your app
Open up,
manifest.yml
similar like: applications:
- name: Lecheebot
random-route: true
memory: 128M
- Run your app locally Ensure that you have installed
pip
in your PC. If not, follow this post: pip and setuptool on windows
now, you can run your app locally by typing the command:
pip install -r requirements.txt
python hello.py
Your app is now accessible at http://localhost:8080
3. Deploy to IBM Bluemix using Cloud Foundry CLI
Ensure you have IBM Bluemix account and installed CF CLI on your machine. if not, follow the steps: [https://github.com/cloudfoundry/cli#downloads
- Log in to CF CLI
Run CMD as administrator, then login to CF with the commands:
cf api https://api.ng.bluemix.net
cf login
Enter your email and password.
- Deploy your app
Open CMD at your app reposit that you cloned in step 2. Execute the command to deploy your app:
cf push
You can view your app status by the command:
cf apps
4. Add Database
- To connect to Cloudant NoSQL DB, follow these steps:
- Navigate to your app. Click on "Connect new" button on Connections Group. Choose Cloudant NoSQL DB service on the categories. Finally, click Create button.
- Ensure that you connect Cloudant NoSQL DB service to your application. If not, click on the "Connect existing" to connect with service.
Now, You can test your app at your app URL.
- To connect Database for working locally:
- Create a file with the name
vcap-local.json
- Add the following detail:
{
"services": {
"cloudantNoSQLDB": [
{
"credentials": {
"username": "<your_username>",
"password": "<your_password>",
"host": "your_host",
"port": 443,
"url": "yoururl"
},
"label": "cloudantNoSQLDB"
}
]
}
}
You can find the username, password, host by click on Cloudant NoSQL DB service at your IBM Blumix console. Then click on "Service Credentials". Copy and pass information to your
vcap-local.json
file.
Now you can test your app locally with the connected database.
python hello.py
It was an excellent article to hear from you which is very useful. Thank you so much for gathering all this information on how to get started with Python Flask Framework on IBM Bluemix, it’s very clever and will be extremely helpful for all people.
ReplyDeleteIt was a great information. Thanks for sharing.
ReplyDeleteOracle Training in Chennai | Certification | Online Training Course | Oracle Training in Bangalore | Certification | Online Training Course | Oracle Training in Hyderabad | Certification | Online Training Course | Oracle Training in Online | Oracle Certification Online Training Course | Hadoop Training in Chennai | Certification | Big Data Online Training Course
Good info. Thanks for sharing.
ReplyDeletePower BI Training
This comment has been removed by the author.
ReplyDeletegood post.
ReplyDeleteDevOps Online Training
Las Vegas casino - Dr.MCD
ReplyDeleteLas Vegas is the most exciting casino in town, and is it 밀양 출장샵 located? 여주 출장마사지 · The 속초 출장마사지 best 의정부 출장샵 casinos for slots in Vegas are at · 안동 출장안마 Play Las Vegas' two best casinos: The
genuinely a gainful article for us. Keep posting, Thank you. Small size power module suppliers
ReplyDeleteNice article. This has a lot of information. Thank you. . Oracle Fusion HCM Training
ReplyDelete