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

30 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
2022-03-02 00:59:31 +02:00
2022-02-26 01:48:16 +02:00
class ThreadingHTTPServer(ThreadingMixIn, HTTPServer):
pass
2022-03-02 00:59:31 +02:00
2022-02-26 01:48:16 +02:00
class MissingEnvironmentVariableError(Exception):
pass
2022-03-02 00:59:31 +02:00
2022-02-26 01:48:16 +02:00
def envOr(key, default):
if key in environ:
return environ[key]
else:
return default
2022-03-02 00:59:31 +02:00
2022-02-26 01:48:16 +02:00
def envOrRaise(key):
if key in environ:
return environ[key]
else:
raise MissingEnvironmentVariableError(key)