Skip to content

Instantly share code, notes, and snippets.

@anopheles
Created January 25, 2012 22:00
Show Gist options
  • Save anopheles/1679063 to your computer and use it in GitHub Desktop.
Save anopheles/1679063 to your computer and use it in GitHub Desktop.
Bottle File Download
# -*- coding: utf-8 -*-
import os, sys, re
from threading import Thread
from bottle import route, run, debug, template, static_file, request, post, get, redirect
from PyQt4 import QtWebKit, QtGui, QtCore, QtNetwork
class DownloadServer(Thread):
def run(self):
debug()
filename = os.path.basename(datei_download)
folder = os.path.dirname(datei_download)
@route("/download/"+filename)
def download():
return static_file(filename, root=folder)
run(host='localhost', port=8080)
if __name__ == "__main__":
app = QtCore.QCoreApplication(sys.argv)
datei_download = r"C:\Windows\notepad.exe"
download_server= DownloadServer()
download_server.start()
sys.exit(app.exec_())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment