Commits

Jason R. Coombs committed 57114f1

Added jaraco.net.http.content.ContentTypeReporter

Comments (0)

Files changed (3)

 ~~~
 
 * Added jaraco.net.importer, featuring URLImporter.
+* Added jaraco.net.http.content.ContentTypeReporter, a cherrypy app to
+  report the content type of uploaded content.
 
 1.5.1
 ~~~~~

jaraco/net/http/content.py

+import cherrypy
+
+form = """
+<form method="post" enctype="multipart/form-data">
+	<input type="file" name="file"/>
+	<input type="submit" />
+</form>
+"""
+class ContentTypeReporter(object):
+	@cherrypy.expose
+	def index(self, file=None):
+		if not file:
+			return form
+		return "Content type is {file.content_type}".format(**vars())
+
+	@classmethod
+	def run(cls):
+		config = {
+			'global': {
+				'server.socket_port': 8080,
+				'server.socket_host': '::0',
+			},
+		}
+		cherrypy.quickstart(cls(), config=config)
 			'tcp-echo-server = jaraco.net.tcp:start_echo_server',
 			'http-headers = jaraco.net.http:headers',
 			'build-dir-index = jaraco.net.site:make_index_cmd',
+			'content-type-reporter = jaraco.net.http.content:ContentTypeReporter.run',
 			],
 	},
 	install_requires=[