<% ' Reads KEY=VALUE secrets from the .env file in the project root (outside the ' public web root). Real environment variables take precedence over the file. Class EnvService_Class Private values Private Sub Class_Initialize() Set values = Server.CreateObject("Scripting.Dictionary") values.CompareMode = 1 LoadFile End Sub Public Function Value(key, fallback) Dim shell : Set shell = Server.CreateObject("WScript.Shell") Value = shell.Environment("Process")(key) Set shell = Nothing If Len(Value) > 0 Then Exit Function If values.Exists(key) Then Value = values(key) Else Value = fallback End If End Function Private Sub LoadFile() Dim fso, path, stream, line, pos, key, val Set fso = Server.CreateObject("Scripting.FileSystemObject") path = Server.MapPath("..\.env") If Not fso.FileExists(path) Then Exit Sub Set stream = fso.OpenTextFile(path, 1, False) Do Until stream.AtEndOfStream line = Trim(stream.ReadLine()) If Len(line) > 0 And Left(line, 1) <> "#" Then pos = InStr(line, "=") If pos > 1 Then key = Trim(Left(line, pos - 1)) val = Trim(Mid(line, pos + 1)) If Len(val) > 1 Then If (Left(val, 1) = """" And Right(val, 1) = """") Or (Left(val, 1) = "'" And Right(val, 1) = "'") Then val = Mid(val, 2, Len(val) - 2) End If values(key) = val End If End If Loop stream.Close End Sub End Class Dim EnvService_Class__Singleton Function EnvService() If IsEmpty(EnvService_Class__Singleton) Then Set EnvService_Class__Singleton = New EnvService_Class End If Set EnvService = EnvService_Class__Singleton End Function %>