Skip to main content

Add your description here

Project description

from typing import Annotated, Literal

from fastapi import Depends, FastAPI, HTTPException, Request, responses

from yemot_api.api_model import ApiModel
from yemot_api.api_response import IdListMessageType, id_list_message, join, routing_yemot
from yemot_api.input_types import FileAction
from yemot_api.yemot_api import Yemot


def verify_yemot(request: Request) -> Literal[True]:
    user_agent = request.headers.get("user-agent")
    if user_agent != "yemot-core-api/1.0":
        raise HTTPException(status_code=403, detail=f"Access denied: {user_agent}")
    return True


class ApiModelExample(ApiModel):
    path: str
    token: str


# app = FastAPI(dependencies=[Depends(verify_yemot)])
app = FastAPI()


@app.get("/foo")
def foo(q: Annotated[ApiModelExample, Depends()]) -> responses.PlainTextResponse:
    yemot_ins = Yemot(f"{q.api_did}:{q.token}")
    if not yemot_ins.check_if_file_exists(q.path):
        return responses.PlainTextResponse("ERROR", 404)
    content = yemot_ins.download_file(q.path)
    with open("testtt.wav", "wb") as f:
        f.write(content)
    yemot_ins.file_action(FileAction.MOVE, q.path, "1")
    res_1 = id_list_message(IdListMessageType.Text, "הנך מועבר למערכת אחרת")
    res_2 = routing_yemot("0773137770")
    res = join([res_1, res_2])
    return responses.PlainTextResponse(res, 200)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

yemot_api-0.1.1.tar.gz (46.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

yemot_api-0.1.1-py3-none-any.whl (37.7 kB view details)

Uploaded Python 3

File details

Details for the file yemot_api-0.1.1.tar.gz.

File metadata

  • Download URL: yemot_api-0.1.1.tar.gz
  • Upload date:
  • Size: 46.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.13

File hashes

Hashes for yemot_api-0.1.1.tar.gz
Algorithm Hash digest
SHA256 eaa5a7e43572446888d4c01cf6cd4eba9343fbacc99e51193a034dd926a38f59
MD5 367fc3462cc88282a5781fc1703d4449
BLAKE2b-256 7771f8e5e596f6147b6502c458e34d24a8fbd082496d3a5e8bc78baa1098fef7

See more details on using hashes here.

File details

Details for the file yemot_api-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: yemot_api-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 37.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.13

File hashes

Hashes for yemot_api-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4f9b55a9ea5008a2f20552f1168c4ff7fcabb8fcb9f69ceadd98a1e64c0cef1d
MD5 6095c304cdaf18682b89bb40014d5a2f
BLAKE2b-256 f455ceae2db55894158518523acb11c4880591b6af40fd3b274d69f565c96919

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page