Demo entry 6634717

Sample Code

   

Submitted by anonymous on Aug 13, 2017 at 12:42
Language: Python. Code size: 710 Bytes.

import cherrypy

scans = []

class Scans:

	exposed = True

	def GET(self):
		return ('Here are all the scans: %s' % scans)

	def POST(self, content):
		# cherrypy.response.status = 404
		# cherrypy.response.headers['Custom-Title'] = "My error"
		# cherrypy.response.headers['Custom-Message'] = "e.g. duplicate record."
		scans.append(content)
		return ('Append new scan with content: %s' % content)

if __name__ == '__main__':

	conf = {
    	'global': {
     	   'server.socket_host': '0.0.0.0',
     	   'server.socket_port': 8080
    	},
    	'/': {
     	   'request.dispatch': cherrypy.dispatch.MethodDispatcher()
    	}
	}

	cherrypy.quickstart(Scans(), '/scans/', conf)
	

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).