Home > other >  Django with Apache deployment cannot be achieved after download function
Django with Apache deployment cannot be achieved after download function

Time:10-02

Use django wrote a simple web page for download resources, resources in the page is in advance on the static, in the debug when everything is normal, but with Apache deployment, resources are unable to download page, prompt can not find a file or directory, the code is as follows:

Views. Py
 
Def the download (request) :
Aa=request. GET # resource path
Bb=request. GET # resource name

File=open (' static \ \ files \ \ '+ aa + + bb' \ \ ', 'rb') # problem in the line
The response=FileResponse (file)
='application/octet - the response stream'
# response='attachment; Filename=\ '+ bb +' \ "" '
The response='attachment; Filename=\ "" + escape_uri_path (bb) + '"'
Return the response


Error: No to the file or directory: 'static \ \ files \ \ xxx1 \ \ xxx2'

Visit the
 http://127.0.0.1/download/? Aa=xxx& Bb=xxx2 
the way, I also tried some absolute paths, not speed, the deployment should be how to operate?

CodePudding user response:

His stick and yourself,,,
  • Related