---
# System prepended metadata

title: when you save the tiktok creat

---


# next steps
0. create a coluumn for the embed in the db
1. when you save the tiktok create the embed url and save it in the db
2. use the embed to serve the page, not the url
3. write a separate script to query the db and add embed codes to missing videos


```python!

def get_embed_from_url(tiktokUrl,conn):
    response = requests.get("https://www.tiktok.com/oembed?url=" + tiktokUrl)
    result = response.json()
    embed_code = result.get("html")
    conn.execute("UPDATE tiktok_videos SET embed_url = %s WHERE tiktok_url = %s", [embed_code,tiktokUrl])
    

```