|
@@ -2,13 +2,27 @@ 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.upsert({'query':domain_name},keys=['query'])
|
|
|
+ db.commit()
|
|
|
+# db.query('select')
|
|
|
+
|
|
|
@app.get("/domain/{domain_name}")
|
|
|
async def test_domain(domain_name):
|
|
|
- return {"item_id": 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():
|