depot/packages/servers/reflex-cache/reflex_cache/util.py

26 lines
509 B
Python
Raw Normal View History

2022-02-26 01:48:16 +02:00
from http.server import HTTPServer
from os import environ
from socketserver import ThreadingMixIn
class Uncached(Exception):
pass
class ThreadingHTTPServer(ThreadingMixIn, HTTPServer):
pass
class MissingEnvironmentVariableError(Exception):
pass
def envOr(key, default):
if key in environ:
return environ[key]
else:
return default
def envOrRaise(key):
if key in environ:
return environ[key]
else:
raise MissingEnvironmentVariableError(key)