import rpyc import time from fastapi import FastAPI import sys import os import dataset import datetime import json db = dataset.connect('sqlite:///similar.db') app = FastAPI() @app.get("/domain/{domain_name}") async def read_item(domain_name): cursor=db.query('select domain_name,json,dt from similar where domain_name="'+domain_name+'"') for c in cursor: print(c['json']) print(c['dt']) return c['json'][1:-1] print(domain_name) conn = rpyc.connect("localhost",12345) #domain_name jsdata=conn.root.get_url('https://data.similarweb.com/api/v1/data?domain='+domain_name) print(jsdata) jsdict=str(jsdata)[1:-1] table=db['similar'] table.insert({'domain_name':domain_name,'json':jsdict,'dt':datetime.datetime.now()}) db.commit() return jsdata # print(jsdata) # return {"item_id": domain_name}