|
|
|
@ -49,13 +49,13 @@ def close_database(exception):
|
|
|
|
|
top.sqlite_db.close() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def init_db(): |
|
|
|
|
@app.cli.command() |
|
|
|
|
def initdb(): |
|
|
|
|
"""Creates the database tables.""" |
|
|
|
|
with app.app_context(): |
|
|
|
|
db = get_db() |
|
|
|
|
with app.open_resource('schema.sql', mode='r') as f: |
|
|
|
|
db.cursor().executescript(f.read()) |
|
|
|
|
db.commit() |
|
|
|
|
db = get_db() |
|
|
|
|
with app.open_resource('schema.sql', mode='r') as f: |
|
|
|
|
db.cursor().executescript(f.read()) |
|
|
|
|
db.commit() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def query_db(query, args=(), one=False): |
|
|
|
@ -217,7 +217,7 @@ def register():
|
|
|
|
|
if not request.form['username']: |
|
|
|
|
error = 'You have to enter a username' |
|
|
|
|
elif not request.form['email'] or \ |
|
|
|
|
'@' not in request.form['email']: |
|
|
|
|
'@' not in request.form['email']: |
|
|
|
|
error = 'You have to enter a valid email address' |
|
|
|
|
elif not request.form['password']: |
|
|
|
|
error = 'You have to enter a password' |
|
|
|
@ -248,8 +248,3 @@ def logout():
|
|
|
|
|
# add some filters to jinja |
|
|
|
|
app.jinja_env.filters['datetimeformat'] = format_datetime |
|
|
|
|
app.jinja_env.filters['gravatar'] = gravatar_url |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__': |
|
|
|
|
init_db() |
|
|
|
|
app.run() |
|
|
|
|