Bivek Gyawali
Bivek Gyawali

Reputation: 136

How to manage python paths in Azure?

So basically how can I manage things that I do with images using opencv and PIL in Azure while hosting?

For my local hosting I can do:

cv2.imread("Upload//img1.jpg")

I am pretty sure I get a 500 code if I host a code with the above line. So what will be equivalent to above line in azure?

Upvotes: 0

Views: 523

Answers (2)

Bivek Gyawali
Bivek Gyawali

Reputation: 136

The problem was my localhost was in Windows but I had hosted my site in Azure linux server. cv2.imread("Upload/img1.jpg") worked for me

Upvotes: 0

Mohit Verma
Mohit Verma

Reputation: 5294

If you are looking for a way to read file using relative path , here is something which you can try :

img1 = os.path.join(os.path.dirname(__file__), 'images', 'main_image.jpg')
main_image = cv2.imread(img1)

Instead of using :

main_image = cv2.imread('Upload/image.jpg')

Hope it helps.

Upvotes: 1

Related Questions