예제 #1
0
	def _register_serverevent(self, sevent, onsevent):
		import os
		import sys
		sys.path.append(os.getcwd() + '\plask')
		from appglobal import cb_mothed
		if not cb_mothed.has_key(self.id):
			cb_mothed[self.id] = {}
		cb_mothed[self.id][sevent] = onsevent
예제 #2
0
 def _register_serverevent(self, sevent, onsevent):
     import os
     import sys
     sys.path.append(os.getcwd() + '\plask')
     from appglobal import cb_mothed
     if not cb_mothed.has_key(self.id):
         cb_mothed[self.id] = {}
     cb_mothed[self.id][sevent] = onsevent
예제 #3
0
    def flaskflush(self):
        import os
        import sys
        sys.path.append(os.getcwd() + '\plask')
        from appglobal import cb_mothed

        if not cb_mothed.has_key(self.id):
            return ""

        sflask = ""
        for key, value in cb_mothed[self.id].iteritems():
            sflask += "@app.route('/" + self.id + "/" + key + "',methods=['POST'])\ndef " + self.id + key + "():\n"
            sflask += "\timport traceback\n\tfrom appglobal import cb_mothed\n\tfrom io import BytesIO\n\timport json\n\tr = {}\n"
            sflask += "\ttry:\n"
            sflask += "\t\tfor cb in cb_mothed[\"" + self.id + "\"][\"" + key + "\"]:\n"
            sflask += "\t\t\tr.update(cb(request.get_json()))\n"
            sflask += "\t\treturn Response(BytesIO(json.dumps(r)), mimetype='text/json')\n"
            sflask += "\texcept:\n"
            sflask += "\t\tfrom log import log\n\t\tlog(traceback.format_exc())\n\n"

        return sflask
예제 #4
0
	def flaskflush(self):
		import os
		import sys
		sys.path.append(os.getcwd() + '\plask')
		from appglobal import cb_mothed
		
		if not cb_mothed.has_key(self.id):
			return ""

		sflask = ""
		for key,value in cb_mothed[self.id].iteritems():
			sflask += "@app.route('/" + self.id + "/" + key + "',methods=['POST'])\ndef " + self.id + key + "():\n"
			sflask += "\timport traceback\n\tfrom appglobal import cb_mothed\n\tfrom io import BytesIO\n\timport json\n\tr = {}\n"
			sflask += "\ttry:\n"
			sflask += "\t\tfor cb in cb_mothed[\"" + self.id + "\"][\"" + key + "\"]:\n"
			sflask += "\t\t\tr.update(cb(request.get_json()))\n"
			sflask += "\t\treturn Response(BytesIO(json.dumps(r)), mimetype='text/json')\n"
			sflask += "\texcept:\n"
			sflask += "\t\tfrom log import log\n\t\tlog(traceback.format_exc())\n\n"
			
		return sflask