mlim-usfca / PersonalKnowledge

https://personal-knowledge.vercel.app
0 stars 0 forks source link

guofan/extract content from the web link #16

Closed GuoFan1996 closed 5 months ago

GuoFan1996 commented 5 months ago

How to Serve and Test the Function:

Serving the Edge Function Locally:

To serve the Edge Function locally for testing and development, use the Supabase CLI with the following command:

supabase functions serve extractContent --no-verify-jwt

By default, Edge Functions require a valid JWT in the authorization header. Since we haven't integrated Auth yet, you can pass the --no-verify-jwt flag when serving this Edge Function without Authorization checks locally.

This command starts a local server that emulates the Supabase environment, allowing you to test the function's behavior before deploying it.

Testing with curl:

curl -i --location --request POST 'http://localhost:54321/functions/v1/extractContent' \
--header 'Content-Type: application/json' \
--data '{"name": "extractContent", "url": "https://example.com"}'

Replace https://example.com with the url you want to extract content.

This PR resolves #7.

inhwaS commented 5 months ago

I just tried this command

inhwa.son@inhwas-air PersonalKnowledge % curl -i --location --request POST 'http://localhost:54321/functions/v1/extractContent' \
--header 'Content-Type: application/json' \
--data '{"name": "extractContent", "url": "https://youtu.be/HAnw168huqA?si=yh9RCB1GJ7kz8zfU"}'

But the result is

HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 14
Connection: keep-alive
vary: Accept-Encoding
date: Mon, 01 Apr 2024 22:33:13 GMT
X-Kong-Upstream-Latency: 1095.0000896454
X-Kong-Proxy-Latency: 4
Via: kong/2.8.1

{"content":""}%  

It can also handle YouTube video right?

inhwaS commented 5 months ago

By the way, I can successfully parse any web content! Looks great ! :)

GuoFan1996 commented 5 months ago

I just tried this command

inhwa.son@inhwas-air PersonalKnowledge % curl -i --location --request POST 'http://localhost:54321/functions/v1/extractContent' \
--header 'Content-Type: application/json' \
--data '{"name": "extractContent", "url": "https://youtu.be/HAnw168huqA?si=yh9RCB1GJ7kz8zfU"}'

But the result is

HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 14
Connection: keep-alive
vary: Accept-Encoding
date: Mon, 01 Apr 2024 22:33:13 GMT
X-Kong-Upstream-Latency: 1095.0000896454
X-Kong-Proxy-Latency: 4
Via: kong/2.8.1

{"content":""}%  

It can also handle YouTube video right?

No, only for general web content, not for youtube transcript.