2016-11-28 1 views
0

파일이 파일 시스템 루트 디렉토리에있을 때 파일을 병에서 다운로드 할 수있게 만드는 방법. 예를 들어, 우분투 운영 체제의 '미디어'디렉토리 안에 있습니까?병이있는 작업/프로젝트 디렉토리 외부에서 파일을 다운로드 할 수있게하십시오.

파이썬 :

#bottle 0.12.10 
@route('/download/<filename:path>') 
def staticdownloadfile(filename): 
    return bottle.static_file(filename, root='/media', download=filename) 

HTML :

<a href="/static/media/somefile.extension">download here</a> 

위의 방법이 작동하지 않는 이유는 무엇입니까? 404 찾을 수 없음. 다른 링크를 사용해야 HTML 파일에서

답변

1

: 때문에 응용 프로그램에

<a href="/download/somefile.extension">download here</a> 

을 당신은 정의 :

@route('/download/<filename:path>') 
관련 문제