-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
29 lines (22 loc) · 780 Bytes
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
from dash import Dash
import dash_html_components as html
import os
from flask import Flask
from flask_simpleldap import LDAP
# Make Dash run on a Flask server
app = Dash(__name__, server=Flask(__name__))
# The Dash app
app.layout = html.P('Hello world!')
# Configure LDAP
app.server.config.update({
'LDAP_BASE_DN': 'OU=users,dc=example,dc=org',
'LDAP_USERNAME': 'CN=user,OU=Users,DC=example,DC=org',
'LDAP_PASSWORD': os.getenv('LDAP_PASSWORD')})
# Protect view functions with LDAP authentication
for view_func in app.server.view_functions:
app.server.view_functions[view_func] = LDAP(app.server).basic_auth_required(app.server.view_functions[view_func])
# Run Flask server
if __name__ == '__main__':
app.run_server()
# For gunicorn
server = app.server