다운로드하는 파일 일 때 필요하며 디렉토리에 액세스 할 때 누구든지 나를 도울 수 있습니까? 때문에 나는 그것을 가져 폴더/파이썬/파이썬/디렉토리로 이동/디렉토리에게 단지/파이썬받는 /Python/
추가하고파일 다운로드 및 디렉토리 액세스 Python (web.py) + HTML
감사
#!/usr/bin/python
import web
import os
urls = (
'/(.*)', 'hello'
)
app = web.application(urls, globals())
class hello:
def GET(self, path):
path = '/Python/'+path
lista = '<html> <body>'
caminhos = [os.path.join(path, nome) for nome in os.listdir(path)]
diretorios = [dire for dire in caminhos if os.path.isdir(dire)]
for dire in diretorios:
# lista = lista+dire+'<br>'
lista = lista+'<a href='+dire+'>'+dire+'</a><br>'
arquivos = [arq for arq in caminhos if os.path.isfile(arq)]
for arq in arquivos:
lista = lista+'<a href='+arq+' target="_blank">'+arq+'</a><br>'
# lista = lista+arq+'<br>'
lista = lista+'<br><br><a href="javascript:window.history.go(-1)">Voltar</a></body> </html>'
return lista
if __name__ == "__main__":
app.run()
덕분에 그것을 넣어,하지만 어떻게 예/파이썬/파이썬/foo는 표시되지 내 코드에 적용? 이해할 수 없었습니다./ – TheGarden
해결책을 업데이트했습니다. – pbuck
대단히 고맙습니다. 그것에 대해 생각해 보지 않았습니다. 내게 많은 도움이되었습니다. 감사합니다. – TheGarden