Pipreqs API Frontend
Frontend page to drive pipreqs-api, which will return the
requirements needed for any Python project hosted with git.
This page is written using PyScript and hosted on Github Pages
Made with ❤️ from Gar's Bar
See the Code 👀
Enter a git(hub / lab) project url containing Python files:
import asyncio
from js import fetch, navigator
async def fetch_text(url: str) -> str:
response = await fetch(url)
return await response.text()
async def fetch_pipreqs(code_url: str) -> str:
return await fetch_text(f"https://pipreqs-api.herokuapp.com/pipreqs?code_url={code_url}")
async def on_submit(*args, **kwargs) -> None:
code_url = Element("code_url").element.value
requirements_card = Element("requirements-card").element
requirements_card.hidden = False
copy_btn = Element("copy-btn").element
copy_btn.hidden = False
requirements = await fetch_pipreqs(code_url)
pyscript.write("requirements", requirements)
async def on_copy(*args, **kwargs) -> None:
requirements = Element("requirements").element.innerHTML
await navigator.clipboard.writeText(requirements)