Skip to content

Commit

Permalink
Update tests and examples
Browse files Browse the repository at this point in the history
  • Loading branch information
pogzyb committed Feb 9, 2024
1 parent 356b2c7 commit b70460a
Show file tree
Hide file tree
Showing 10 changed files with 799 additions and 1,009 deletions.
334 changes: 0 additions & 334 deletions asyncwhois/pywhois.py

This file was deleted.

9 changes: 5 additions & 4 deletions examples/async-web.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
# https://docs.aiohttp.org/en/stable/web_quickstart.html
import httpx
from aiohttp import web

import asyncwhois


async def whois_handler(request):
domain = request.match_info.get('domain', 'google.com')
domain = request.match_info.get("domain", "google.com")
result = await asyncwhois.aio_whois_domain(domain)
return web.Response(
text=f'WhoIs Query Parsed:\n{result.parser_output}\nQuery Output:\n{result.query_output}'
text=f"WhoIs Query Parsed:\n{result.parser_output}\nQuery Output:\n{result.query_output}"
)


app = web.Application()
app.add_routes([web.get('/whois/{domain}', whois_handler)])
app.add_routes([web.get("/whois/{domain}", whois_handler)])
web.run_app(app)

#
Expand All @@ -23,4 +24,4 @@ async def whois_handler(request):
# localhost:8080/whois/netflix.com
# localhost:8080/whois/google.com
# localhost:8080/whois/pypi.org
#
#
19 changes: 19 additions & 0 deletions examples/authoritative-only.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import asyncwhois


def main():
domain = "google.com"

# show the entire query-chain answer
result = asyncwhois.whois_domain(domain, authoritative_only=False) # default
print(result.query_output)

# only show the "authoritative" answer
result = asyncwhois.whois_domain(domain, authoritative_only=True)
print(result.query_output)

return


if __name__ == "__main__":
main()
Loading

0 comments on commit b70460a

Please sign in to comment.