Pyhton Web App deployment fails on render

Hi I want to deploy a web app from github - GitHub - ianuvrat/stock_mda_repo
Deploy logs indicate successful builds, However, every deployment attempt ends up in a failed state. Since the logs are not helpful, I’m not sure how I can find the cause of the failure.

I want to deploy a python web app (using dash and plotly and openAI) on render which uses an Open AI API key that must stay confidential.

I stored the API key in ‘.env’ file and that .env file is in .gitignore. I then pushed app files to GitHub repo.

My app works in local machine, however, when I try to deploy using render service, the deployment fails. Any idea what would be wrong? I also tried manually deploying many times still it fails.

P.S. I have also added an environment variable in render API with same variable and api key and still could not deploy.

This is my sample code where I’m fetching API.

import openai
from dotenv import load_dotenv
import os
#Load environment variables from .env file
#Environment variables

def generate_text(prompt):
openai.api_key = OPENAI_API_KEY
response = openai.Completion.create(
text = response[“choices”][0][“text”]
return text

Hey there,

You probably want to try some debugging output after setting OPENAI_API_KEY to see if its what you expect it is here,

A reminder that Render support is here to support Render the platform and not customer application code that’s running on us.


John B

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.