19 lines
548 B
Python
19 lines
548 B
Python
from flask import current_app, g
|
|
import os
|
|
|
|
|
|
def get_users():
|
|
if 'users' not in g:
|
|
users = {}
|
|
authfile = current_app.config['AUTHFILE']
|
|
|
|
current_app.logger.debug('Reading %s for users', authfile)
|
|
|
|
with current_app.open_resource(os.path.join("..",
|
|
authfile)) as f:
|
|
for entry in f:
|
|
users.update({tuple(entry.decode('ascii').strip().split(':', 1))})
|
|
g.users = users
|
|
current_app.logger.debug(g.users)
|
|
return g.users
|