-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from modularizer/micro
Micro independence
- Loading branch information
Showing
26 changed files
with
1,364 additions
and
269 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,34 @@ | ||
from .server import Server | ||
from .handlers import RouteHandler, StaticFileHandler, MatchableHandlerABC | ||
from .types import ( | ||
Request, | ||
Response, | ||
HTTPStatusCode, | ||
HTMLResponse, | ||
JSONResponse, | ||
ErrorResponse, | ||
FileResponse, | ||
FileTypeResponse, | ||
RedirectResponse, | ||
TemporaryRedirect, | ||
PermanentRedirect, | ||
RequestBody, | ||
Query, | ||
Body, | ||
Route, | ||
FullPath, | ||
Method, | ||
File, | ||
ClientAddr, | ||
Headers, | ||
set_default_error_mode, | ||
url_encode, | ||
url_decode | ||
) | ||
from .tags import ( | ||
tag, | ||
methods, | ||
get, | ||
post, | ||
put, | ||
patch, | ||
delete | ||
) | ||
|
||
serve = Server.serve | ||
|
||
def _spoof_modules(which="all"): | ||
from socketwrench.settings import config | ||
config["spoof_modules"] = which | ||
|
||
def set_socket_module(module): | ||
from socketwrench.settings import config | ||
if not hasattr(module, "socket"): | ||
raise ValueError("socket module must have a 'socket' attribute. expecting a module like that from 'import socket'") | ||
config["socket_module"] = module | ||
|
||
|
||
class _unspecified: | ||
pass | ||
|
||
|
||
def serve(*args, spoof_modules=_unspecified, socket=_unspecified, log_level=None, **kwargs): | ||
if spoof_modules is not _unspecified: | ||
_spoof_modules(spoof_modules) | ||
if socket is not _unspecified: | ||
set_socket_module(socket) | ||
import socketwrench.public | ||
if log_level is not None: | ||
from socketwrench.standardlib_dependencies import logging | ||
logging.basicConfig(level=log_level) | ||
return socketwrench.public.serve(*args, **kwargs) | ||
|
||
|
||
def __getattr__(name): | ||
# import from public | ||
if name == "_spoof_modules": | ||
return _spoof_modules | ||
import socketwrench.public | ||
return getattr(socketwrench.public, name) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.