changeset 20:67ca17753cd5

NEW - # 12: create table and upload data https://it-dev.mpiwg-berlin.mpg.de/tracs/GIS/ticket/12
author casties
date Wed, 18 Aug 2010 16:20:25 +0200
parents 060797795a4d
children a67b7c1f7ec5
files RestDbInterface.py
diffstat 1 files changed, 10 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/RestDbInterface.py	Wed Aug 18 11:54:18 2010 +0200
+++ b/RestDbInterface.py	Wed Aug 18 16:20:25 2010 +0200
@@ -215,8 +215,16 @@
 
             logging.debug("put with schema=%s table=%s file=%s"%(schema,tablename,file))
             ret = self.createTableFromXML(schema, tablename, file)
-            # set content type to json(?)
-            json.dump(ret, RESPONSE)
+            resultType = REQUEST.get("result_type","application/json")
+            if resultType == "application/json":
+                RESPONSE.setHeader("Content-Type", "application/json")
+                json.dump(ret, RESPONSE)
+            elif resultType == "html/json":
+                RESPONSE.setHeader("Content-Type", "text/html")
+                RESPONSE.write("<html>\n<body>\n<pre>")
+                json.dump(ret, RESPONSE)
+                RESPONSE.write("</pre>\n</body>\n</html>")
+                
             
         else:
             # 400 Bad Request