AndroidDev
AndroidDev

Reputation: 16385

URL for postgress DB on HEROKU

I am new to Python, and looking to deploy a simple application to HEROKU. I have added a postgress instance to HEROKU. I am trying to see the URL of the postgress database. Here is my code

import os
from flask import Flask

app = Flask(__name__)
@app.route('/')
def hello():
    return os.environ.get("DATABASE_URL","NONE")

But i am always getting none, what am i doing wrong?

Upvotes: 0

Views: 52

Answers (1)

raam86
raam86

Reputation: 6871

You need to open a hosted postgres database. You will get a URL after you create your account.

Also it seems like the syntax is:

return os.environ['DATABASE_URL']

Upvotes: 1

Related Questions