Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import bottle
- from bottle import route, run, Bottle
- import sys, os, re, urllib
- #fcpHost = "127.0.0.1"
- #import fcp
- #node = fcp.FCPNode(host=fcpHost, verbosity=fcp.DETAIL)
- app = Bottle()
- #m1="'"
- def delim_filter(config):
- bottle.debug(True)
- print("Entering delim_filter")
- ''' Matches a comma separated list of numbers. '''
- aconfig = config or "%20"
- print ("aconfig=" + aconfig)
- delimiter = urllib.unquote(aconfig).decode('utf8')
- print("delimiter=" + delimiter)
- regexp = r'(?!{a_delim})+({a_delim}(?!%s)+)*'.format(a_delim=re.escape(delimiter))
- def to_python(match):
- print("Converting Match")
- print("Math=" + match)
- ms = map(urllib.unquote(aconfig).decode,match.split())
- print( "ms=" + ms )
- return ms
- def to_url(astr):
- print("Converting to URL")
- print ("astr=" + astr)
- astr2 = delimiter.join(map(urllib.unquote(aconfig).decode,astr))
- print("astr2="+astr2)
- print astr2
- return astr2
- return regexp, to_python, to_url
- app.router.add_filter('delim', delim_filter)
- @app.route('/<key>/%09/<cmd>/<args:delim:%09>') # %09 == tab
- @app.route('/<key>/%20/<cmd>/<args:delim:%20>') # %20 == ' '
- @app.route('/<key>/ /<cmd>/<args:delim: >') # %20 == ' '
- @app.route('/<key>/%3B/<cmd>/<args:delim:%3B>') # %3B == ';'
- @app.route('/<key>/%2C/<cmd>/<args:delim:%2C>') # %2C == ','
- def mystery(key,cmd,args,aconfig='%2C'):
- bottle.debug(True)
- if key == '1234': # %2C == ','
- print(key)
- print(cmd)
- print(args)
- delimiter = urllib.unquote(aconfig).decode('utf8')
- print(delimiter)
- #os.system("IFS=<a_dilim>".format(a_dilim=dilimiter))
- #os.system("cmd" + "delimiter" + delimiter.join(args))
- return ('key=' + key + '<br>' +
- 'delimiter=' + delimiter + '<br>' +
- 'cmd=' + cmd + '<br>' +
- 'args=' + args)
- #@app.route('/USK@<hashKey:nocomma>,<ecryptionKey:nocomma>,<encryption:nocomma>/<metaData:path>')
- #def hello(hashKey,ecryptionKey,encryption,metaData):
- #
- # mimetype, val1 = node.get(uri)
- # return ('hashKey=' + hashKey + '<br>' +
- # 'ecryptionKey=' + ecryptionKey + '<br>' +
- # 'encryption=' + encryption + '<br>' +
- # 'metaData=' + metaData)
- #
- #Regular eressions use a seperate filter; https://bottlepy.org/docs/dev/routing.html
- app.run(host='localhost', port=8082, debug=True)
Add Comment
Please, Sign In to add comment