def do_GET(self): self.send_response(200) self.send_header('Content-type', 'text') self.end_headers() parsed = urlparse(self.path) qs = parse_qs(parsed.query) result = "" if len(qs) > 0: ns = qs['n'] if len(ns) > 0: n = int(ns[0]) result = str(f(n)) self.wfile.write(bytes(result, "utf-8")) self.wfile.write(bytes(result, "utf-8"))
from fib import f n = input("n:") n = int(n) print(f(n))
def handle(self, request:str): n = int(request) print('f(n)=', f(n)) pass
def test_f(self): self.assertEqual(f(1), 1) self.assertEqual(f(2), 2) self.assertEqual(f(3), 3) self.assertEqual(f(4), 5) self.assertEqual(f(10), 89)