IBM Cloud Platform as a Service

Cloud Platform as a Service

Join us to learn more from a community of collaborative experts and IBM Cloud product users to share advice and best practices with peers and stay up to date regarding product enhancements, regional user group meetings, webinars, how-to blogs, and other helpful materials.

 View Only
Expand all | Collapse all

Getting Started with Python Flask IBM Cloudant

  • 1.  Getting Started with Python Flask IBM Cloudant

    Posted Mon August 09, 2021 09:08 AM
    Hi all. My query is if there are any examples other than the one provided by IBM to get started with python in the cloud

    GitHub - IBM-Cloud/get-started-python: 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.
    GitHub remove preview
    GitHub - IBM-Cloud/get-started-python: 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.
    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. - GitHub - IBM-Cloud/get-started-python: A Python application and tutorial that use Flask framework to provide a REST API to receive requests from the UI.
    View this on GitHub >
     

    That is, my query consists of getting help at least, documentation, examples and everything necessary for a CRUD (Create, Read, Update, Delete) with Cloudant, Python and Flask. Your answer would be of great help. Thanks.

    ------------------------------
    Cristhian Gerardo Sandoval
    ------------------------------


  • 2.  RE: Getting Started with Python Flask IBM Cloudant

    Posted Mon August 09, 2021 02:52 PM
    Hi Cristhian,

    Please check, below link. It might help with your queries. It also has a sample app.

    https://dataplatform.cloud.ibm.com/docs/content/wsj/analyze-data/ml-python-flask-mnist-tutorial.html

    The database part is not there it seems. But you can include the database code like below for a Mongodb database.

    ==============
    from flask import Flask, request, jsonify
    from pymongo import MongoClient
    from flask_cors import CORS
    from bson.objectid import ObjectId
    .
    .
    .

    app = Flask(__name__)
    CORS(app)


    MONGODB_USER = ""
    MONGODB_PASSWORD = ""
    MONGODB_DATABASE = ""
    MONGODB_DOMAIN = ""
    MONGODB_PORT = ""

    try:
    if(MONGODB_USER == None or MONGODB_PASSWORD == None):
    MONGODB_URL = "mongodb://"+MONGODB_DOMAIN+":"+MONGODB_PORT
    else:
    MONGODB_URL = "mongodb://"+MONGODB_USER+":"+MONGODB_PASSWORD+"@"+MONGODB_DOMAIN+":"+MONGODB_PORT
    ============================

    Regards,
    Rakib Hossain

    ------------------------------
    Rakib Hossain Molla
    ------------------------------