Esempio n. 1
0
def main():

    if db.exists() is True:
        p = db.path()
        print ""
        print "Database already exists: %s" % (p)
        print ""
        exit(1)

    print ""
    print "Creating database..."
    db.create()
    print ""
    username = "******"
    password = ''.join(random.choice(string.lowercase) for i in range(8))
    newuser = User.create(username, password)
    print "New user '%s' created with password '%s'" % (username, password)

    return
Esempio n. 2
0
def urlcheck(short, short1=None, short2=None):
        if short1 is not None:
            short = short + "/" + short1
        if short2 is not None:
            short = short + "/" + short2

        match = Url.match(short.lower())
        if match is None:
            return "No match found"

        match.hits_record(request.remote_addr)

        # finally redirect
        return redirect(match.dest, code=302)


@app.route("/")
def index():
    return redirect("http://www.uknof.org.uk", code=302)

if __name__ == '__main__':

    if Database.exists() is False:
        print ""
        print "Please run dbsetup.py"
        print ""
        exit(1)

    app.debug = True
    app.run()