Jason R. Coombs avatar 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=[
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.