def main(): #get firstname firstname = raw_input( "Enter firstname: " ) #get lastname lastname = raw_input( "Enter lastname: " ) #get username username = raw_input( "Enter username: "******"Enter password: "******"Enter email: " ) email.replace( '@', '\@' ) #get database name dbname = raw_input( "Enter database name: " ) #preload items? preload = None while not((preload == "y") or (preload == "n")): preload = raw_input( "Preload database? (y/n): " ) #admin account admin = None while not((admin == 'T') or (admin == 'F')): admin = raw_input( "Admin account? (T/F): " ) if admin == 'T': admin = 1 elif admin == 'F': admin = 0 #setup db db = db_driver.database( dbname ) db.setup() db.adduser( firstname, lastname, username, password, email, admin ) #write to config dbname and username config = ConfigParser.RawConfigParser() config.add_section('shop') config.set('shop', 'username', username) config.set('shop', 'dbname', dbname ) with open( 'shop.cfg', 'wb') as fh: config.write( fh ) if preload == "y": with open( "loaditems.sql", "r" ) as fh: for line in fh: cur = db.connect() cur.execute( """ {} """.format( line ) ) db.conn.commit() cur.close()
import copy import ConfigParser app = Flask(__name__) config = ConfigParser.ConfigParser() config.read( 'shop.cfg' ) dbname = config.get( 'shop', 'dbname' ) adminusername = config.get( 'shop', 'username' ) app.secret_key = os.urandom( 24 ) UPLOAD_FOLDER = 'static/img' app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER db = db_driver.database(dbname) #replace with code to make sure the schemas match if not os.path.exists( dbname ): db.setup() @app.route("/favicon.ico") def icon(): """Return a redirect to the favicon""" return redirect( url_for( "static", filename="favicon.ico" ) ) @app.route("/api/categories", methods=['GET', 'POST']) @app.route("/api/categories/<uid>", methods=['PUT', 'DELETE', 'GET']) def get_categories(uid=None): """Return a list of categories""" if uid != None: