98
99
#req.content_type = "application/json"
99
100
req.write_html_head_foot = False # No HTML
102
# Get all the arguments, if POST.
103
# Ignore arguments if not POST, since we aren't allowed to cause
104
# side-effects on the server.
107
if req.method == 'POST':
108
fields = req.get_fieldstorage()
109
action = fields.getfirst('action')
111
if action is not None:
112
handle_action(req, action, fields)
116
def handle_action(req, action, fields):
117
"""Perform the "action" part of the response.
118
This function should only be called if the response is a POST.
119
This performs the action's side-effect on the server. If unsuccessful,
120
writes the X-IVLE-Action-Error header to the request object. Otherwise,
121
does not touch the request object. Does NOT write any bytes in response.
123
action: String, the action requested. Not sanitised.
124
fields: FieldStorage object containing all arguments passed.
127
path = fields.getfirst('path')
131
def handle_return(req):
132
"""Perform the "return" part of the response.
133
This function returns the file or directory listing contained in
134
req.path. Sets the HTTP response code in req, writes additional headers,
135
and writes the HTTP response, if any."""
103
138
req.write('{"app": "File Service"}\n')