import os

from flask import Flask
from flask_sse import sse

app = Flask(__name__)
app.config["REDIS_URL"] = os.environ.get(
    "REDIS_URL",
    "redis://localhost/2"
)
app.register_blueprint(sse, url_prefix='/events')

import os

from flask import Flask
from flask_sse import sse

app = Flask(__name__)
redis_host =  os.environ.get("KV_HOST", "localhost")
redis_port =  os.environ.get("KV_PORT", "5379")
redis_url = "redis://%s:%s/2" % (redis_host, redis_port)

app.config["REDIS_URL"] = redis_url
app.register_blueprint(sse, url_prefix='/events')

Use right env variable to build redis url
Use right env variable to build redis url

It is for the events stream daemon.

  import os
  
  from flask import Flask
  from flask_sse import sse
  
  app = Flask(__name__)
- app.config["REDIS_URL"] = os.environ.get(
-     "REDIS_URL",
-     "redis://localhost/2"
- )
+ redis_host =  os.environ.get("KV_HOST", "localhost")
+ redis_port =  os.environ.get("KV_PORT", "5379")
+ redis_url = "redis://%s:%s/2" % (redis_host, redis_port)
+ 
+ app.config["REDIS_URL"] = redis_url
  app.register_blueprint(sse, url_prefix='/events')
  
Use right env variable to build redis url
## Code Before:
import os

from flask import Flask
from flask_sse import sse

app = Flask(__name__)
app.config["REDIS_URL"] = os.environ.get(
    "REDIS_URL",
    "redis://localhost/2"
)
app.register_blueprint(sse, url_prefix='/events')

## Instruction:
Use right env variable to build redis url
## Code After:
import os

from flask import Flask
from flask_sse import sse

app = Flask(__name__)
redis_host =  os.environ.get("KV_HOST", "localhost")
redis_port =  os.environ.get("KV_PORT", "5379")
redis_url = "redis://%s:%s/2" % (redis_host, redis_port)

app.config["REDIS_URL"] = redis_url
app.register_blueprint(sse, url_prefix='/events')
