File tree Expand file tree Collapse file tree 1 file changed +10
-6
lines changed
Expand file tree Collapse file tree 1 file changed +10
-6
lines changed Original file line number Diff line number Diff line change 66ALLOWED_HOSTS = [os .environ ['WEBSITE_HOSTNAME' ]] if 'WEBSITE_HOSTNAME' in os .environ else []
77CSRF_TRUSTED_ORIGINS = ['https://' + os .environ ['WEBSITE_HOSTNAME' ]] if 'WEBSITE_HOSTNAME' in os .environ else []
88
9- # Configure Postgres database; the full username for PostgreSQL flexible server is
10- # username (not @sever-name).
9+ # Configure Postgres database based on connection string of the libpq Keyword/Value form
10+ # https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNSTRING
11+ conn_str = os .environ ['AZURE_POSTGRESQL_CONNECTIONSTRING' ]
12+ #conn_str= 'dbname=msdocs-python-postgres-psfdj-database host=msdocs-python-postgres-psfdj-server.postgres.database.azure.com port=5432 sslmode=require user=bazbufjyde password=PASSWORD$'
13+ conn_str_params = {pair .split ('=' )[0 ]: pair .split ('=' )[1 ] for pair in conn_str .split (' ' )}
14+
1115DATABASE_URI = 'postgresql+psycopg2://{dbuser}:{dbpass}@{dbhost}/{dbname}' .format (
12- dbuser = os . environ [ 'DBUSER ' ],
13- dbpass = os . environ [ 'DBPASS ' ],
14- dbhost = os . environ [ 'DBHOST' ] + ".postgres.database.azure.com" ,
15- dbname = os . environ [ 'DBNAME ' ]
16+ dbuser = conn_str_params [ 'user ' ],
17+ dbpass = conn_str_params [ 'password ' ],
18+ dbhost = conn_str_params [ 'host' ] ,
19+ dbname = conn_str_params [ 'dbname ' ]
1620)
You can’t perform that action at this time.
0 commit comments