Buckets:
AnonymousSpottedToad/candidate_bucket / codebase /python /Chainlit_chainlit /cypress /e2e /ask_file /main.py
| import aiofiles | |
| import chainlit as cl | |
| async def start(): | |
| files = await cl.AskFileMessage( | |
| content="Please upload a text file to begin!", accept=["text/plain"] | |
| ).send() | |
| txt_file = files[0] | |
| async with aiofiles.open(txt_file.path, encoding="utf-8") as f: | |
| content = await f.read() | |
| await cl.Message( | |
| content=f"`Text file {txt_file.name}` uploaded, it contains {len(content)} characters!" | |
| ).send() | |
| files = await cl.AskFileMessage( | |
| content="Please upload a python file to begin!", | |
| accept={ | |
| "text/plain": [".py", ".txt"], | |
| # Some browser / os report it as text/plain but some as text/x-python when doing drag&drop | |
| "text/x-python": [".py"], | |
| # Or even as application/octet-stream when using the select file dialog | |
| "application/octet-stream": [".py"], | |
| }, | |
| ).send() | |
| py_file = files[0] | |
| async with aiofiles.open(py_file.path, encoding="utf-8") as f: | |
| content = await f.read() | |
| await cl.Message( | |
| content=f"`Python file {py_file.name}` uploaded, it contains {len(content)} characters!" | |
| ).send() | |
Xet Storage Details
- Size:
- 1.2 kB
- Xet hash:
- e1282969fea14f8f79f306b072bc4269598bd24aa77ad97c2fc3c2354ee71f35
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.