generated from Luis/nextjs-python-web-template
push first sql setup try
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
import time
|
||||
from typing import List, Optional
|
||||
|
||||
from fastapi import APIRouter, BackgroundTasks, Depends, Request
|
||||
from httpx import AsyncClient
|
||||
from fastapi import APIRouter, BackgroundTasks, Depends
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from .. import sql_crud, sql_db, sql_models
|
||||
@@ -112,7 +113,7 @@ def create_repository(
|
||||
response_model=List[Repository],
|
||||
tags=[Tags.repositories],
|
||||
)
|
||||
def get_repositories(get
|
||||
def get_repositories(
|
||||
skip: int = 0, limit: int = 100, db: Session = Depends(sql_db.get_db)
|
||||
) -> List[sql_models.Repository]:
|
||||
repositories = sql_crud.get_repositories(db, skip=skip, limit=limit)
|
||||
@@ -203,12 +204,13 @@ async def attach(
|
||||
return {"message": "Attaching in the background"}
|
||||
|
||||
# TODO
|
||||
def attach_entity(entity_did: str, db: Session) -> None:
|
||||
async def attach_entity(entity_did: str, db: Session) -> None:
|
||||
db_entity = sql_crud.set_attached_by_entity_did(db, entity_did, True)
|
||||
try:
|
||||
while db_entity.attached:
|
||||
#query status endpoint
|
||||
subprocess.run(f'curl http://{db_entity.ip}')
|
||||
async with AsyncClient(app=app, base_url=f"http://{db_entity.ip}") as ac:
|
||||
response = await ac.get("/")
|
||||
# test with: while true; do { echo -e 'HTTP/1.1 200 OK\r\n'; echo '<html>test</html>'; } | nc -l 5556; done
|
||||
#except not reached set false
|
||||
time.sleep(1)
|
||||
|
||||
Reference in New Issue
Block a user