def commandHandler(args,url): client = replitdb.Client(url) command = args[0].lower() if(command=='add'): sub = args[1].split('=') client.add_dict({sub[0]:sub[1]}) elif(command=='remove'): client.remove(args[1]) elif(command=='list'): print(client.list(args[1])) elif(command=='view'): print(client.view(args[1])) elif(command=='search'): print(client.list(args[1])) elif(command=='all'): print(client.all_dict) elif(command=='wipe'): client.wipe print("wiped") else: print(f"{command} is not a valid command")
import flask, requests, replitdb db = replitdb.Client() app = flask.Flask(__name__) @app.route('/') def main(): return flask.render_template('index.html', url=None) @app.route('/Invalid URL') def invalid(): return flask.redirect('/') @app.route('/', methods=['POST']) def add(): newURL = flask.request.form['add'] valid = False allURLs = db.view('allURLs') try: requests.get(newURL) valid = True except: url = 'Invalid URL' if valid: lastNum = int(allURLs[-1], base=16) newNum = str(hex(lastNum + 1))[2:]
menu = int(input("Options \n 1: Save to DB \n 2: Get from DB")) #importing replit dB #explorer only (I think) #thx codermoney 51 for making this module import replitdb client = replitdb.Client() if menu == 1: name = input("What would you like to name your save in the database\n") value = input("What would you like to assign it to?\n") client.add(name=value) elif menu == 2: name = input("What name would you like to get from the database?\n") print(client.view(name)) else: print("not an option")