This repository has been archived by the owner on Jul 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
42 additions
and
0 deletions.
There are no files selected for viewing
5 changes: 5 additions & 0 deletions
5
hyko_toolkit/functions/web/web_scraping/pdf_downloader/Dockerfile
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
FROM hyko-sdk:latest | ||
|
||
COPY . . | ||
|
||
CMD ["uvicorn", "--host", "0.0.0.0", "--port", "3000", "main:func"] |
14 changes: 14 additions & 0 deletions
14
hyko_toolkit/functions/web/web_scraping/pdf_downloader/main.py
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import requests | ||
from hyko_sdk.io import PDF | ||
from hyko_sdk.models import CoreModel, Ext | ||
from metadata import Inputs, Outputs, func | ||
|
||
|
||
@func.on_execute | ||
async def main(inputs: Inputs, params: CoreModel) -> Outputs: | ||
# Send a GET request to the url | ||
response = requests.get(inputs.url) | ||
response.raise_for_status() | ||
# If the GET request is successful, add the content to the list | ||
data = response.content | ||
return Outputs(pdf=PDF(val=data, obj_ext=Ext.PDF)) |
23 changes: 23 additions & 0 deletions
23
hyko_toolkit/functions/web/web_scraping/pdf_downloader/metadata.py
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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
from hyko_sdk.definitions import ToolkitFunction | ||
from hyko_sdk.io import PDF | ||
from hyko_sdk.models import CoreModel | ||
from pydantic import Field | ||
|
||
func = ToolkitFunction( | ||
name="pdf_downloader", | ||
task="web_scraping", | ||
description="This function downloads content from a URL and returns it as a PDF object.", | ||
) | ||
|
||
|
||
@func.set_input | ||
class Inputs(CoreModel): | ||
url: str = Field( | ||
..., | ||
description="Your Target PDF URL.", | ||
) | ||
|
||
|
||
@func.set_output | ||
class Outputs(CoreModel): | ||
pdf: PDF = Field(..., description="The Downloaded PDF.") |