1234567891011121314151617181920212223242526272829303132 |
- from fastapi import FastAPI
- import sys
- import os
- import dataset
- import requests
- db = dataset.connect('sqlite:////tmp/hhh.db')
- app = FastAPI()
- def check_db(domain_name):
- global db
- table=db['q_cache']
- table.insert({'domain_name':domain_name})
- # table.upsert({'query':domain_name},keys=['query'])
- db.commit()
- # db.query('select')
- @app.get("/domain/{domain_name}")
- async def test_domain(domain_name):
- check_db(domain_name)
- r = requests.get('https://data.similarweb.com/api/v1/data?domain='+domain_name)
- js=r.json()
- #https://data.similarweb.com/api/v1/data?domain=hhh.com.tw
- return {"item_id": js}
- @app.get("/")
- async def root():
- return {"message": "test"}
|