I wish when the user clicks on a link say.
http://www.xyz.com/dynamic-text.py
The browser will prompt user to save the text file.
The following script will make browser to prompt user to save 开发者_运维技巧dynamic-text.py. I wish to prompt user to save some-file-name.txt. How can I do so?
dynamic-text.py
#!c:/Python27/python.exe -u
print "Content-type: text/text"
print
print "This is Text File"
You can send the Content-Disposition HTTP header:
print "Content-Type: text/plain"
print "Content-Disposition: attachment; filename=some-file-name.txt"
print
Also note that you should use the text/plain content type instead of text/text which, to my knowledge, doesn't exist.
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论