创建您的免费 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 控制面板,点击“Settings”并在 Config Vars 下设置 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/ 查看您的应用程序