Skip to content

Commit

Permalink
Merge pull request #197 from czasg/feat/ctxprint
Browse files Browse the repository at this point in the history
feat: 支持ctx.print
  • Loading branch information
czasg authored Dec 6, 2023
2 parents faf7947 + 20678dc commit 235d30d
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions pywss/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,15 @@ def __flush_body(self):
chunk = body.read(8192)
body.close()

def __str__(self):
firstline = f"{self.method} {self.route} {self.version}"
header = '\r\n'.join([f"{k}: {v}" for k, v in self.headers.items()])
body = self.body().decode()
return f"{firstline}\r\n{header}\r\n\r\n{body}"

def __bytes__(self):
return self.body()


class App:

Expand Down Expand Up @@ -706,6 +715,8 @@ def watchdog(self, interval: float = float(os.environ.get("PYWSS_WATCHDOG_INTERV
key = f"{route}"
handler = handlers[-1]
module = inspect.getmodule(handler)
if module.__name__ == "__main__": # only restart
continue
sourcefile = inspect.getsourcefile(module)
mtime = int(os.path.getmtime(sourcefile))
if key not in stat:
Expand Down

0 comments on commit 235d30d

Please sign in to comment.