A simple web application that allows invitation based registration to a matrix instance
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

20 lines
386 B

6 years ago
  1. import os
  2. import sqlite3
  3. from flask import g
  4. DATABASE = os.getenv("DATA_DIRECTORY", ".") + "/data.db"
  5. def get_db():
  6. db = getattr(g, '_database', None)
  7. if db is None:
  8. db = g._database = sqlite3.connect(DATABASE)
  9. return db
  10. @app.teardown_appcontext
  11. def close_connection(exception):
  12. db = getattr(g, '_database', None)
  13. if db is not None:
  14. db.close()