Skip to content

Commit

Permalink
remove printing env values
Browse files Browse the repository at this point in the history
  • Loading branch information
yoomlam committed Jun 8, 2024
1 parent 44214b4 commit cbf6f4c
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions 05-assistive-chatbot/chatbot_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,18 +70,17 @@ def healthcheck(request: Request):

@app.post("/initenvs")
def initenvs(env_file_contents: str = Body()):
print(f"{type(env_file_contents)}: {env_file_contents}")
env_values = dotenv.dotenv_values(stream=StringIO(env_file_contents))
values_changed = []
vars_updated = []
for name, value in env_values.items():
if name.endswith("_API_KEY") or name.endswith("_API_TOKEN") or name in ALLOWED_ENV_VARS:
logger.info("Setting environment variable %s", name)
os.environ[name] = value or ""
values_changed.append(name)
vars_updated.append(name)
else:
logger.warning("Setting environment variable %s is not allowed!", name)
chatbot.reset()
return str(values_changed)
return str(vars_updated)


if __name__ == "__main__":
Expand Down

0 comments on commit cbf6f4c

Please sign in to comment.