<commit_before>__author__ = '<NAME>'
__version__ = '0.1.2'
__license__ = 'MIT'

from bottle import route, request, response, view, send_file, run
import redis
import bottle

# -- PRELIMINARIES ----------------------------------------

# Bottle debug - remove in production!

bottle.debug(True)

# The main redis object

r = redis.Redis()

# Set static file routing

@route('/static/:filename')
def static_file(filename):
    send_file(filename, root='../redbottle/static')

# -- CENTRAL PAGE -----------------------------------------

# Central page for all operations

@route('/central/')
@view('central')
def template_keyvalue():  
    db_size = r.dbsize()
    return dict(db_size=db_size)

# -- UNIVERSALS -------------------------------------------

@route('/delete/', method='post')
@view('central')
def template_delete():

    key_delete = request.post.get('key_delete', '').strip()
    r.delete(key_delete)
    db_size = r.dbsize()	
	   
    return dict(db_size = db_size, key=key_delete)

@route('/delete/all/', method='post')
@view('central')
def template_delete_all():

    delete_all = request.post.get('delete_all', '').strip()
    r.flushdb()
    db_size = r.dbsize()

    return dict(db_size = db_size)

# -- STRINGS --------------------------------------------- 

# SET |

@route('/strings/set/', method='post')
@view('strings')
def template_add():
    key = request.post.get('key', '').strip()
    value = request.post.get('value', '').strip()

    r.set(key,value)
    db_size = r.dbsize()
 
    return dict(key=key, db_size=db_size, value=value)


# GET |

@route('/strings/get/' method='post')
@view('strings')
def template_show(key):
    key = request.post.get('key', '').strip()
    show_value = r.get(key)	
	
    return dict(key=key, show_value=show_value)	

# -- LISTS ----------------------------------------------

# RPUSH | append an element to the tail of a list

@route('/lists/rightpush/', method='post')
@view('lists')
def template_lists_rightpush():
    key = request.post.get('key', '').strip()
    member = request.post.get('member', '').strip()

    r.push(key,member)
    db_size = r.dbsize()
 
    return dict(key=key, member=member, db_size=db_size)


# LPUSH | append an element to the head of a list

@route('/lists/leftpush/', method='post')
@view('lists')
def template_lists_leftpush():
    key = request.post.get('key', '').strip()
    member = request.post.get('member', '').strip()

    r.push(key,member, tail=True)
    db_size = r.dbsize()
 
    return dict(key=key, member=member, db_size=db_size)


# LLEN | return the length of a list

@route('/lists/length/' method='post':)
@view('lists')
def template_lists_length():
    key = request.post.get('key', '').strip()
    length = r.llen(key)
    dbsize = r.dbsize()

    return dict(key=key, length=length, db_size=db_size)


# LRANGE | return a range of elements from a list

@route('/lists/range/' method='post')
@view('lists')
def template_lists_range():
    key = request.post.get('key', '').strip()
    start = request.post.get('start', '').strip()
    end = request.post.get('end', '').strip()
    range = r.lrange(key, start, end)
    db_size = r.dbsize()

    return dict(key=key, range=range, db_size=db_size)

# LTRIM
# LINDEX
# LSET
# LREM<commit_msg>fixed problem with reserved word 'range'<commit_after>__author__ = '<NAME>'
__version__ = '0.1.2'
__license__ = 'MIT'

from bottle import route, request, response, view, send_file, run
import redis
import bottle

# -- PRELIMINARIES ----------------------------------------

# Bottle debug - remove in production!

bottle.debug(True)

# The main redis object

r = redis.Redis()

# Set static file routing

@route('/static/:filename')
def static_file(filename):
    send_file(filename, root='../redbottle/static')

# -- CENTRAL PAGE -----------------------------------------

# Central page for all operations

@route('/central/')
@view('central')
def template_keyvalue():  
    db_size = r.dbsize()
    return dict(db_size=db_size)

# -- UNIVERSALS -------------------------------------------

@route('/delete/', method='post')
@view('central')
def template_delete():

    key_delete = request.post.get('key_delete', '').strip()
    r.delete(key_delete)
    db_size = r.dbsize()	
	   
    return dict(db_size = db_size, key=key_delete)

@route('/delete/all/', method='post')
@view('central')
def template_delete_all():

    delete_all = request.post.get('delete_all', '').strip()
    r.flushdb()
    db_size = r.dbsize()

    return dict(db_size = db_size)

# -- STRINGS --------------------------------------------- 

# SET |

@route('/strings/set/', method='post')
@view('strings')
def template_add():
    key = request.post.get('key', '').strip()
    value = request.post.get('value', '').strip()

    r.set(key,value)
    db_size = r.dbsize()
 
    return dict(key=key, db_size=db_size, value=value)


# GET |

@route('/strings/get/' method='post')
@view('strings')
def template_show(key):
    key = request.post.get('key', '').strip()
    show_value = r.get(key)	
	
    return dict(key=key, show_value=show_value)	

# -- LISTS ----------------------------------------------

# RPUSH | append an element to the tail of a list

@route('/lists/rightpush/', method='post')
@view('lists')
def template_lists_rightpush():
    key = request.post.get('key', '').strip()
    member = request.post.get('member', '').strip()

    r.push(key,member)
    db_size = r.dbsize()
 
    return dict(key=key, member=member, db_size=db_size)


# LPUSH | append an element to the head of a list

@route('/lists/leftpush/', method='post')
@view('lists')
def template_lists_leftpush():
    key = request.post.get('key', '').strip()
    member = request.post.get('member', '').strip()

    r.push(key,member, tail=True)
    db_size = r.dbsize()
 
    return dict(key=key, member=member, db_size=db_size)


# LLEN | return the length of a list

@route('/lists/length/' method='post':)
@view('lists')
def template_lists_length():
    key = request.post.get('key', '').strip()
    length = r.llen(key)
    dbsize = r.dbsize()

    return dict(key=key, length=length, db_size=db_size)


# LRANGE | return a range of elements from a list

@route('/lists/range/' method='post')
@view('lists')
def template_lists_range():
    key = request.post.get('key', '').strip()
    start = request.post.get('start', '').strip()
    end = request.post.get('end', '').strip()
    list_range = r.lrange(key, start, end)
    db_size = r.dbsize()

    return dict(key=key, list_range=list_range, db_size=db_size)

# LTRIM
# LINDEX
# LSET
# LREM
{'fraction_non_alphanumeric': 0.23163669612922888, 'fraction_numerical': 0.0009143553794574825, 'mean_word_length': 2.9158711217183773, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7439365', 'n_tokens_mistral': 2244, 'n_tokens_neox': 2197, 'n_words': 480}