Напишем веб-сервер с использованием bottle (20 строк кода)
Для использования нужен пакет bottle:
easy_install bottle
# coding: utf-8
from bottle import run, route, send_file
import os
# список текущих файлов
@route('/')
def main():
msg = ''
for file in os.listdir('.'):
if os.path.isfile(file): msg += '<a href="%s">%s</a><br/>\n' % (file,file)
return '<html><body>%s</body></html>' % (msg,)
# отправка файла
@route(':filename')
def sendfile(filename):
send_file(filename, './')
# запуск сервера
run(host='', port=8080)