0

I have been using the following python 3 script in a CDSW session which run just fine as long as the session is not killed.

I am able to click on the top-right grid and select my app

enter image description here

hello.py

from flask import Flask
import os

app = Flask(__name__)

@app.route('/')
def index():
    return 'Web App with Python Flask!'

app.run(host=os.getenv("CDSW_IP_ADDRESS"), port=int(os.getenv('CDSW_PUBLIC_PORT')))

I would like this app to run 24/7, so instead of using a Session or scheduling a job that never ends, I would like to create a CDSW Application so that it doesn't stop.

This is the settings on my application:

enter image description here

Logs:

from flask import Flask
import os
app = Flask(__name__)
@app.route('/')
def index():
    return 'Web App with Python Flask!'
app.run(host=os.getenv("CDSW_IP_ADDRESS"), port=int(os.getenv('CDSW_PUBLIC_PORT')))
 * Serving Flask app "__main__" (lazy loading)
 * Environment: production
   WARNING: Do not use the development server in a production environment.
   Use a production WSGI server instead.
 * Debug mode: off
OSError: [Errno 98] Address already in use

I tried to change the port from CDSW_PUBLIC_PORT to CDSW_APP_PORT but it ends up the same.

legends1337
  • 69
  • 1
  • 7

1 Answers1

0

As it mentions here maybe you need to change this line of code

app.run(host=os.getenv("CDSW_IP_ADDRESS"), port=int(os.getenv('CDSW_PUBLIC_PORT')))

to this

app.run(host="127.0.0.1", port=int(os.environ['CDSW_APP_PORT']))

Hope it works!