/usr/share/doc/python-medusa-doc/examples/publish.py is in python-medusa-doc 1:0.5.4-7.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | # -*- Mode: Python -*-
# Demonstrates use of the auth and put handlers to support publishing
# web pages via HTTP.
# It is also possible to set up the ftp server to do essentially the
# same thing.
# Security Note: Using HTTP with the 'Basic' authentication scheme is
# only slightly more secure than using FTP: both techniques involve
# sending a unencrypted password of the network (http basic auth
# base64-encodes the username and password). The 'Digest' scheme is
# much more secure, but not widely supported yet. <sigh>
import asyncore
from medusa import default_handler
from medusa import http_server
from medusa import put_handler
from medusa import auth_handler
from medusa import filesys
# For this demo, we'll just use a dictionary of usernames/passwords.
# You can of course use anything that supports the mapping interface,
# and it would be pretty easy to set this up to use the crypt module
# on unix.
users = { 'mozart' : 'jupiter', 'beethoven' : 'pastoral' }
# The filesystem we will be giving access to
fs = filesys.os_filesystem('/home/medusa')
# The 'default' handler - delivers files for the HTTP GET method.
dh = default_handler.default_handler(fs)
# Supports the HTTP PUT method...
ph = put_handler.put_handler(fs, '/.*')
# ... but be sure to wrap it with an auth handler:
ah = auth_handler.auth_handler(users, ph)
# Create a Web Server
hs = http_server.http_server(ip='', port=8080)
# install the handlers we created:
hs.install_handler(dh) # for GET
hs.install_handler(ah) # for PUT
asyncore.loop()
|