Spaces:
No application file
No application file
Download examples/rest-api/services.py from rajesh1501/embedchain: direct link, hf CLI and curl.
- Browser
- Download file 657 Bytes
-
https://huggingface.co/spaces/rajesh1501/embedchain/resolve/main/examples/rest-api/services.py
- Command line
-
hf download hf://spaces/rajesh1501/embedchain/examples/rest-api/services.py
-
curl -L -o services.py https://huggingface.co/spaces/rajesh1501/embedchain/resolve/main/examples/rest-api/services.py
657 Bytes
| from models import AppModel | |
| from sqlalchemy.orm import Session | |
| def get_app(db: Session, app_id: str): | |
| return db.query(AppModel).filter(AppModel.app_id == app_id).first() | |
| def get_apps(db: Session, skip: int = 0, limit: int = 100): | |
| return db.query(AppModel).offset(skip).limit(limit).all() | |
| def save_app(db: Session, app_id: str, config: str): | |
| db_app = AppModel(app_id=app_id, config=config) | |
| db.add(db_app) | |
| db.commit() | |
| db.refresh(db_app) | |
| return db_app | |
| def remove_app(db: Session, app_id: str): | |
| db_app = db.query(AppModel).filter(AppModel.app_id == app_id).first() | |
| db.delete(db_app) | |
| db.commit() | |
| return db_app | |