创建您的免费 Redis Cloud 帐户。 点击这里创建 Redis Cloud 订阅和数据库,如下所示:
保存数据库端点 URL 和密码以供将来参考。
如果您是第一次使用 Heroku,请创建您的新 Heroku 帐户 通过此链接
brew install heroku
heroku login
heroku: Press any key to open up the browser to login or q to exit:
Opening browser to https://cli-auth.heroku.com/auth/cli/browser/XXXXXXXXXXA
Logging in... done
Logged in as your_email_address
在本演示中,我们将使用 示例速率限制应用程序
git clone https://github.com/redis-developer/basic-rate-limiting-demo-python
运行以下 CLI 以获得一个包含简单应用程序和 package.json 文件的功能齐全的 Git 存储库。
$ heroku create
Creating app... done, ⬢ fast-reef-76278
https://fast-reef-76278.herokuapp.com/ | https://git.heroku.com/fast-reef-76278.git
转到 Heroku 仪表板,点击“设置”并设置 REDIS_ENDPOINT_URI
和 REDIS_PASSWORD
在配置变量下。请参考步骤 1。
Heroku 为您的应用程序生成一个随机名称(在本例中为 fast-reef-76278),或者您可以传递一个参数来指定您自己的应用程序名称。现在部署您的代码
$ git push heroku
Enumerating objects: 512, done.
Counting objects: 100% (512/512), done.
Delta compression using up to 12 threads
Compressing objects: 100% (256/256), done.
Writing objects: 100% (512/512), 1.52 MiB | 660.00 KiB/s, done.
Total 512 (delta 244), reused 512 (delta 244)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Building on the Heroku-20 stack
remote: -----> Determining which buildpack to use for this app
remote: -----> Python app detected
…
emote: -----> Compressing...
remote: Done: 59.3M
remote: -----> Launching...
remote: Released v5
remote: https://fast-reef-76278.herokuapp.com/ deployed to Heroku
remote:
remote: Verifying deploy... done.
To https://git.heroku.com/fast-reef-76278.git
* [new branch] master -> master
打开 https://fast-reef-76278.herokuapp.com/ 查看您的应用程序