Advertisement
s243a

SSK_Parse

Nov 4th, 2018
264
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.15 KB | None | 0 0
  1. from bottle import route, run, Bottle
  2. #This doesn't work because this isn't the correct way to use regular expressions.
  3. import re
  4.  
  5. #These four inputs from tutorial: https://github.com/blueyed/lib-pyFreenet-staging/blob/master/tutorial.py
  6. import sys, os
  7.  
  8. app = Bottle()
  9.  
  10. def nocomma_filter(config):
  11.     ''' Matches a comma separated list of numbers. '''
  12.  
  13.     regexp = r'[^,/@]+'
  14.     print config
  15.     def to_python(match):
  16.         print  match
  17.         return match
  18.  
  19.     def to_url(astr):
  20.         print  astr
  21.         return astr
  22.  
  23.     return regexp, to_python, to_url
  24.  
  25. app.router.add_filter('nocomma', nocomma_filter)
  26. @app.route('/USK@<hashKey:nocomma>,<ecryptionKey:nocomma>,<encryption:nocomma>/<metaData:path>')
  27. def hello(hashKey,ecryptionKey,encryption,metaData):
  28.    
  29.     mimetype, val1 = node.get(uri)
  30.     return ('hashKey=' + hashKey + '<br>' +
  31.              'ecryptionKey=' + ecryptionKey + '<br>' +
  32.              'encryption=' + encryption + '<br>' +
  33.              'metaData='   + metaData)
  34.              
  35. #Regular eressions use a seperate filter; https://bottlepy.org/docs/dev/routing.html
  36. app.run(host='localhost', port=8081, debug=True)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement