All Projects → IBM-Cloud → Get Started Python

IBM-Cloud / Get Started Python

Licence: apache-2.0
A Python application and tutorial that use Flask framework to provide a REST API to receive requests from the UI. The API then persists the data to a Cloudant database.

Programming Languages

javascript
184084 projects - #8 most used programming language
python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Get Started Python

Lofocats ui
LofoCats UI is a simple web application consuming the LofoCats API, built with Ruby on Rails 🐱
Stars: ✭ 54 (-48.08%)
Mutual labels:  tutorial, sample
Sqlite Web
Web-based SQLite database browser written in Python
Stars: ✭ 1,169 (+1024.04%)
Mutual labels:  database, flask
Llvm 9.0 Learner Tutorial
A blog for LLVM(v9.0.0 or v11.0.0) beginner, step by step, with detailed documents and comments. Record the way I learn LLVM and accomplish a complete project for FPGA High-Level Synthesis with it.
Stars: ✭ 58 (-44.23%)
Mutual labels:  tutorial, sample
Syscrack
Virtual Online Crime Simulator (VOCS) written in PHP 7.0
Stars: ✭ 17 (-83.65%)
Mutual labels:  database, tutorial
Flask Wtform Tutorial
📝😎Tutorial to implement forms in your Flask app.
Stars: ✭ 84 (-19.23%)
Mutual labels:  flask, tutorial
Viewtooltip
A fluent tooltip for Android
Stars: ✭ 1,029 (+889.42%)
Mutual labels:  tutorial, sample
Flask Session Tutorial
💾 🙇 Example Flask project for implementing Flask-Session with Redis.
Stars: ✭ 69 (-33.65%)
Mutual labels:  flask, tutorial
Tutoshowcase
A simple and Elegant Showcase view for Android
Stars: ✭ 499 (+379.81%)
Mutual labels:  tutorial, sample
Deploying Flask To Heroku
Deploying a Flask App To Heroku Tutorial
Stars: ✭ 81 (-22.12%)
Mutual labels:  flask, tutorial
Data Driven Web Apps With Pyramid And Sqlalchemy
Demos and handouts for Talk Python's Data-Driven Web Apps with Pyramid and SQLAlchemy course
Stars: ✭ 79 (-24.04%)
Mutual labels:  database, tutorial
Demo Multi Lang
Simple libp2p demos implemented in Go, JS and Rust
Stars: ✭ 17 (-83.65%)
Mutual labels:  tutorial, sample
Uikit Playground
Blog posts about things I learned over the years working with UIKit and accompanying sample code.
Stars: ✭ 95 (-8.65%)
Mutual labels:  tutorial, sample
Eliasdb
EliasDB a graph-based database.
Stars: ✭ 611 (+487.5%)
Mutual labels:  database, tutorial
Eve Building Restful Mongodb Backed Apis Course
Course materials and handouts for EVE: Building RESTful MongoDB-backed APIs course
Stars: ✭ 53 (-49.04%)
Mutual labels:  flask, tutorial
Rxjava2 Android Samples
RxJava 2 Android Examples - Migration From RxJava 1 to RxJava 2 - How to use RxJava 2 in Android
Stars: ✭ 4,950 (+4659.62%)
Mutual labels:  tutorial, sample
Flask Tutorial
A tutorial to build your first flask application
Stars: ✭ 58 (-44.23%)
Mutual labels:  flask, tutorial
Flask Tutorial
Flask 入门教程:使用 Python 和 Flask 开发你的第一个 Web 程序
Stars: ✭ 365 (+250.96%)
Mutual labels:  flask, tutorial
Firebase Instagram
📸 Instagram clone with Firebase Cloud Firestore, Expo, and React Native 😁😍
Stars: ✭ 389 (+274.04%)
Mutual labels:  database, tutorial
Shorty
🔗 A URL shortening service built using Flask and MySQL
Stars: ✭ 78 (-25%)
Mutual labels:  database, flask
Flask Tutorial
这个项目已经很久很久了, 不推荐看, 不过倒是可以进群叨逼叨一下. 🚗 交流群:630398887
Stars: ✭ 91 (-12.5%)
Mutual labels:  flask, tutorial

Getting Started with Python on IBM Cloud

To get started, we'll take you through a sample Python Flask app, help you set up a development environment, deploy to IBM Cloud and add a Cloudant database.

The following instructions are for deploying the application as a Cloud Foundry application. To deploy as a container to IBM Cloud Kubernetes Service instead, see README-kubernetes.md

Prerequisites

You'll need the following:

1. Clone the sample app

Now you're ready to start working with the app. Clone the repo and change to the directory where the sample app is located.

git clone https://github.com/IBM-Cloud/get-started-python
cd get-started-python

Peruse the files in the get-started-python directory to familiarize yourself with the contents.

2. Run the app locally

Install the dependencies listed in the requirements.txt file to be able to run the app locally.

You can optionally use a virtual environment to avoid having these dependencies clash with those of other Python projects or your operating system.

pip install -r requirements.txt

Run the app.

python hello.py

View your app at: http://localhost:8000

3. Prepare the app for deployment

To deploy to IBM Cloud, it can be helpful to set up a manifest.yml file. One is provided for you with the sample. Take a moment to look at it.

The manifest.yml includes basic information about your app, such as the name, how much memory to allocate for each instance and the route. In this manifest.yml random-route: true generates a random route for your app to prevent your route from colliding with others. You can replace random-route: true with host: myChosenHostName, supplying a host name of your choice. Learn more...

applications:
- name: GetStartedPython
  random-route: true
  memory: 128M

4. Deploy the app

You can use the Cloud Foundry CLI to deploy apps.

Choose your API endpoint

cf api <API-endpoint>

Replace the API-endpoint in the command with an API endpoint from the following list.

URL Region
https://api.ng.bluemix.net US South
https://api.eu-de.bluemix.net Germany
https://api.eu-gb.bluemix.net United Kingdom
https://api.au-syd.bluemix.net Sydney

Login to your IBM Cloud account

cf login

From within the get-started-python directory push your app to IBM Cloud

cf push

This can take a minute. If there is an error in the deployment process you can use the command cf logs <Your-App-Name> --recent to troubleshoot.

When deployment completes you should see a message indicating that your app is running. View your app at the URL listed in the output of the push command. You can also issue the

cf apps

command to view your apps status and see the URL.

5. Add a database

Next, we'll add a NoSQL database to this application and set up the application so that it can run locally and on IBM Cloud.

  1. Log in to IBM Cloud in your Browser. Browse to the Dashboard. Select your application by clicking on its name in the Name column.
  2. Click on Connections then Connect new.
  3. In the Data & Analytics section, select Cloudant NoSQL DB and Create the service.
  4. Select Restage when prompted. IBM Cloud will restart your application and provide the database credentials to your application using the VCAP_SERVICES environment variable. This environment variable is only available to the application when it is running on IBM Cloud.

Environment variables enable you to separate deployment settings from your source code. For example, instead of hardcoding a database password, you can store this in an environment variable which you reference in your source code. Learn more...

6. Use the database

We're now going to update your local code to point to this database. We'll create a json file that will store the credentials for the services the application will use. This file will get used ONLY when the application is running locally. When running in IBM Cloud, the credentials will be read from the VCAP_SERVICES environment variable.

  1. Create a file called vcap-local.json in the get-started-python directory with the following content:
{
  "services": {
    "cloudantNoSQLDB": [
      {
        "credentials": {
          "username":"CLOUDANT_DATABASE_USERNAME",
          "password":"CLOUDANT_DATABASE_PASSWORD",
          "host":"CLOUDANT_DATABASE_HOST"
        },
        "label": "cloudantNoSQLDB"
      }
    ]
  }
}
  1. Back in the IBM Cloud UI, select your App -> Connections -> Cloudant -> View Credentials

  2. Copy and paste the username, password, and host from the credentials to the same fields of the vcap-local.json file replacing CLOUDANT_DATABASE_USERNAME, CLOUDANT_DATABASE_PASSWORD, and CLOUDANT_DATABASE_URL.

  3. Run your application locally.

python hello.py

View your app at: http://localhost:8000. Any names you enter into the app will now get added to the database.

  1. Make any changes you want and re-deploy to IBM Cloud!
cf push

View your app at the URL listed in the output of the push command, for example, myUrl.mybluemix.net.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].