I used dcc.upload() to handle the file upload. The file can be uploaded and read locally on the localhost.
But after the deployment, I received POST 500 internal server error. And the message received is:
{message: "Callback error updating output-data-upload.children", html: "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 3.2 Final/…ded or there is an error in the application.</p>\n"}
The code related to this error message has been attached below as a screenshot, where output-data-upload is the id of a html.Div() component.
And the upload-data is the id of the dcc.Upload() component.
In the parse_contents(), I'm trying to filter for xls or xlsx files only. in the update_output(), I'm trying to display the name of the uploaded file.
I've looked up the 500 error code and have tried to change some permission settings but nothing really worked out.\
I really appreciate the help!
code related
Related
I'm trying to add the paypal button to my django shopping site.
I have used the code from the SDK and replaced the id:
My code:
Client ID being: AWeSepzeHNW8BHE8rWPVm6CTuAGKz7SS1WzpbqEOZvQw-s_6qwFg6lxCO9MSXPpcVheUBWRgNuW6yKol
However i am receiving a 400 error.
Also viewing the page source shows the src has changed:
If you follow this link you get the following message:
throw new Error("SDK Validation error: 'Invalid query value for client-id: AabgYuFGxyzy3AbeWLPa-EtEGGreyL9bDDbWOxH4zFbPbgNc7y5yMpNO7B2NMRxCvT7-Ysou8ZXDNycT¤cy=USD'" );
/* Original Error:
Invalid query value for client-id: AabgYuFGxyzy3AbeWLPa-EtEGGreyL9bDDbWOxH4zFbPbgNc7y5yMpNO7B2NMRxCvT7-Ysou8ZXDNycT¤cy=USD (debug id: f3776258140b9)
*/
Anyone know why the src has been changed from the source to when its rendered by django?
I have followed the original src link from paypal and this, however when the page renders the link is altered.
I found out what the problem was. I had to replace the & with & in the
<script src="https://www.paypal.com/sdk/js?client-id=test¤cy=USD"></script>
tag.
I tried to download a document in my telegram bot hosted in heroku, but in the server (heroku) the file don´t send to user, when this make a request.
In local it´s right and function, the document send with no problem.
This is the code, i use the library gdown to download file to Google Drive:
url = 'link to document in drive (mode view for all with link)'
output = 'List.pdf'
doc = gdown.download(url, output, quiet=False)
bot.sendDocument(chat_id=ChatId, document=open('list.pdf', 'rb'), filename=output)
In local runing the file is downloading without problem
But if i send to heroku server with docker and start service, the bot not send to user the PDF.
I created an if when FileNotFoundError (because that error sheds heroku), but always goes to if, and not send the file (I puted a link to view the document, but is not the same)
¿Any idea to solve?
I am trying to create a simple web application to upload multiple images using Blobstore. I have managed to upload the images successfully to the Blobstore. But when the images get uploaded, it simply shows a blank page with the URL like: myapplicationId.appstore.com/_ah/upload/.…(keyvalue). When I try to get image from key it shows me blank page. I am stuck.
In logs it shows 200 with no size of file.
Following is code snippet.
class ServeHandler(blobstore_handlers.BlobstoreDownloadHandler):
def get(self, resource):
print "get img"
resource = str(urllib.unquote(resource))
blob_info = blobstore.BlobInfo.get(resource)
self.response.out.write(blob_info)
or
self.send_blob(blob_info)
I have checked the db images are there. this handler is called and I also got print statement working.
I have also deployed the code to GAE same issue on local and GAE as well.
Following is the url I am making.
http://127.0.0.1:8585/serve/9lYtH7BmLoI7qOTaYlG8UA==
I am new to django. I am trying to serve downloadable files using django FileWrapper. But, I keep getting internal server error messages.
EDIT: My settings.py
DEBUG=True
link in html:
abcd.com/downloadResult/fileName/
My urls.py
url(r'^downloadResult/(\w{0,50})/$',"myApp.views.showResult",name="Result"),
My views.py
from django.core.servers.basehttp import FileWrapper
def showResult(request,fileName):
file=open("/path/to/file/"+fileName+".txt","r")
response=HttpResponse(FileWrapper(file),mimetype='application/force-download')
response['Content-Disposition']='attachment; filename=%s' % smart_str(fileName+".txt")
file.close()
return response
Can someone please direct me to some discussions or point out what I am missing?
Thanks!
I figured out the problem with my code. I closed the file before I return anything. After commenting out the second last line in views.py, it works fine. I found the error message in apache log file but did not get any error message in the browser even though DEBUG was set to True.
Now, the problem with this solution is that, there are files that are opened but never closed.
I am working on bugzilla xml-rpc by using "Bugzilla XMLRPC access module" developed in python.
How I can attach/download bugzilla file by using this module ?
According to guideline of API get_attachments_by_bug($bug_id) retrieves and returns the attachments.
But this function didn't worked for me, I got following error message.
<type 'exceptions.AttributeError'>: 'Bugzilla4' object has no attribute 'get_attachments_by_bug'
Any help would be appreciated.
FYI:
I am in contact with supplier of python-bugzilla tool and here I got response from them.
"Not all bugzilla XMLRPC APIs are wrapped by python-bugzilla, that's one of them.
The 'bugzilla' command line tool that python-bugzilla ships has commands for
attaching files and downloading attachments, take a look at the code there for
guidance."
I've figured out the way how to download/upload attachment by using "Bugzilla XMLRPC access module"
you need to pass the id of attached file as parameter to the following function
Download:
downloaded_file = bz.download_attachment(attachment_id)
file_name = str(downloaded_file.name)
Upload:
kwards = {
'contenttype':'application/octet-stream',
# 'filename': file_path #there could be more parameters if needed
}
#attachfile method will return the id of attached file
bz.attachfile(bug_id, file_path, file_name, **kwards)
However attached file got corrupted due to some xmp-rpc API's internal methods described here, here and here, that's another issue :)