Esempio n. 1
0
def Main():

	uriQuery = cgi.FieldStorage()                # Get the query string from the URI
	if uriQuery.has_key('lastfm') or uriQuery.has_key('gnat'):
		if uriQuery.has_key('lastfm'):
			lastfmUser = uriQuery['lastfm'].value
			# mopy can't handle the last-fm service
			# lastfmRDF = mopy.importRDFFile(lastfmURI+lastfmUser)




		if uriQuery.has_key('gnat'):
			gnatFile = uriQuery['gnat'].file.read()
			print "Content-type: text/html\n\n"
			f = open('temp.rdf', 'w')
			for char in gnatFile:
				f.write(char)

			f.close()
			try:
				rdf = mopy.importRDFFile('temp.rdf')
				tracks = rdf.TrackIdx.keys()
				op = []
			except:
				print "bad file, maybe not a GNAT output..."
				return
			#try:
			for track in tracks:
				#t = callCrawl(track)
				#t.start()
				crawler.find(track)
				#brand_recommender.find(track)
			#except:
			#	print "threading problem"
			#	return
				#print op
			
			print "gnat tracks: <br>"
			print tracks
			print op
	else:
		print "must submit an RDF file"
Esempio n. 2
0
def api_lastfound():
    regex = request.args.get('regex', '')
    js = json.dumps({'response': c.find(regex)})
    resp = Response(js, status=200, mimetype='application/json')
    return resp
Esempio n. 3
0
	def run(self):
		crawler.find(self.track)