没有Redis配置!使用rq-dashboard的简单flask应用程序的错误

qcuzuvrc  于 12个月前  发布在  Redis
关注(0)|答案(1)|浏览(179)

rq-dashboard在命令行中工作,但没有集成到flask中。
github的简单示例

from flask import Flask
import rq_dashboard

app = Flask(__name__)
app.config.from_object(rq_dashboard.default_settings)
rq_dashboard.web.setup_rq_connection(app)
app.register_blueprint(rq_dashboard.blueprint, url_prefix="/rq")

@app.route("/")
def hello():
    return "Hello World!"

if __name__ == "__main__":
    app.run()

字符串
返回下面的错误

File "rq_db.py", line 6, in <module>
rq_dashboard.web.setup_rq_connection(app)
/python/site-packages/rq_dashboard/web.py", line 74, in setup_rq_connection
raise RuntimeError("No Redis configuration!")
RuntimeError: No Redis configuration!


我在虚拟环境中使用了rhel 8和Flask 3.0、python 3.11、redis 5.0.3、redis-py 5.0.1、rq 1.15.1、rq-dashboard 0.6.7和mod_wsgi

eivgtgni

eivgtgni1#

尽管我使用的是默认的redis url,但我需要在Flask应用程序中指定它。
工作代码为:

from flask import Flask
import rq_dashboard

app = Flask(__name__)
app.config.from_object(rq_dashboard.default_settings)
app.config["RQ_DASHBOARD_REDIS_URL"] = "redis://127.0.0.1:6379"
rq_dashboard.web.setup_rq_connection(app)
app.register_blueprint(rq_dashboard.blueprint, url_prefix="/rq")

@app.route("/")
def hello():
    return "Hello World!"

if __name__ == "__main__":
    app.run()

字符串

相关问题