Reputation: 383
Building a python 3 web app using flask which includes google maps.
Checking for API Key before loading index.html always raises RuntimeError:
if not os.environ.get("key"):
raise RuntimeError("key not set")
return render_template("index.html", key=os.environ.get("key"))
Also tried os.getenv
- the same problem occurs. Changing variable name does not solve the issue either.
Exported the variable to environment via export key=value
and printenv
returns correct value of key
.
Hardcoding the API Key works and returns the map successfully:
return render_template("index.html", key=value)
Any ideas how to solve this?
Upvotes: 0
Views: 1728