This example demonstrates how to create and use a Flask application.
Consider the following code example for using a Flask application:
from flask import Flask
from werkzeug import serving
import re, os
app = Flask(__name__)
@app.route("/")
def hello_world():
return "<p>Hello, World!</p>"
@app.route("/foo2")
def hello_world2():
return "<p>Hello, World!</p>"
@app.route('/fit_update', methods=["POST"])
def fit_update():
return "<p>Fit Update: " + str(request.get_json()) + "</p>"
if __name__ == '__main__':
PORT = os.getenv('CDSW_READONLY_PORT', '8090')
app.run(host="127.0.0.1", port=int(PORT))
When creating or modifying an application, you can specify a new value for the
CDSW_APP_POLLING_ENDPOINT environmental variable. Update the
CDSW_APP_POLLING_ENDPOINT in the Project Settings and add the
following to your code:Figure 1. Setting CDSW_APP_POLLING_ENDPOINT in Project Settings