Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

app.py 1.0KB

123456789101112131415161718192021222324252627282930313233
  1. from typing import Annotated, List
  2. from fastapi import FastAPI, Query
  3. from million.model.filter.MessageFilter import MessageFilter, MessageOrder
  4. from million.model.filter.ParticipantFilter import ParticipantFilter
  5. from million.model.message import Message
  6. from million.analyze.filter.message import filter as message_filter
  7. from million.analyze.filter.participants import ParticipantCount, filter as participants_filter
  8. from million.model.participant import Participant
  9. import million.parse.fb_exports as fb
  10. DATA_PATH = './data/'
  11. export = fb.parse_dirfiles(DATA_PATH)
  12. app = FastAPI()
  13. class GetMessageForm(MessageFilter):
  14. order: MessageOrder = None
  15. limit: int = 100
  16. @app.get("/messages")
  17. def read_messages(
  18. form: Annotated[GetMessageForm, Query()]
  19. ) -> List[Message]:
  20. return message_filter(export.messages, form, form.order, form.limit)
  21. @app.get("/participants")
  22. def read_participants(form: Annotated[ParticipantFilter, Query()]) -> List[ParticipantCount]:
  23. return participants_filter(export.messages, export.participants, form)