2
# Copyright (C) 2007-2008 The University of Melbourne
4
# This program is free software; you can redistribute it and/or modify
5
# it under the terms of the GNU General Public License as published by
6
# the Free Software Foundation; either version 2 of the License, or
7
# (at your option) any later version.
9
# This program is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
# GNU General Public License for more details.
14
# You should have received a copy of the GNU General Public License
15
# along with this program; if not, write to the Free Software
16
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22
# This is an IVLE application.
23
# A sample / testing application for IVLE.
25
from common import util
31
"""Handler for the Server application which serves pages.
32
For most file types we just serve the static file, but
33
for python files, we evaluate the python script inside
34
our safe execution environment."""
36
if req.path.endswith('.py'):
37
raise Exception, "executing python not done yet!"
39
# We're expecting paths are all of the form <usr>/...
40
parts = req.path.split('/')
42
raise Exception, "empty path!"
46
# The corresponding file on the filesystem
47
path = conf.root_dir + '/jails/' + user + '/home/' + req.path
50
(type, encoding) = mimetypes.guess_type(path)
55
# Set request attributes
56
req.content_type = type
57
if encoding is not None:
58
req.content_encoding = encoding
60
req.write_html_head_foot = False