Reputation: 373
Now i am working on production server (AzureWebsites) and i want to open my .txt
files.
This is the tree that i used to save my stopwords.txt
-App
-media
-App
stopwords.txt
-static
-templates
settings.py
MEDIA_ROOT = path.join(PROJECT_ROOT, 'media').replace('\\', '/')
# URL that handles the media served from MEDIA_ROOT. Make sure to use a
# trailing slash.
# Examples: "http://media.lawrence.com/media/", "http://example.com/media/"
MEDIA_URL = '/media/'
I want to open the text file using this command
handle = open('/media/stopwords.txt', 'r+')
var = handle.read()
This is the error i got when run my app
[Errno 13] Permission denied: '/media/stopwords.txt'
and when i try to modify the open statements with this
handle = open(settings.MEDIA_ROOT + 'stopwords.txt', 'r+')
i got this error
[Errno 2] No such file or directory: 'D:/home/site/wwwroot/mediastopwords.txt'
Can anyone please help fix this problem?
Upvotes: 0
Views: 196
Reputation: 17621
According to your tree stopwords is stored under /media/App/stopwords.txt So to open it you need:
handle = open(settings.MEDIA_ROOT + '/App/stopwords.txt', 'r+')
Upvotes: 0
Reputation: 106
Try handle = open(settings.MEDIA_ROOT + '/stopwords.txt', 'r+')
Upvotes: 1