Skip to content

Commit

Permalink
docs: Update docs with preferred way of displaying documents #2291 (#…
Browse files Browse the repository at this point in the history
…2311)

Co-authored-by: Martin Turoci <[email protected]>
  • Loading branch information
marek-mihok and mturoci authored Apr 12, 2024
1 parent bd27d0d commit 293c837
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
Binary file added assets/examples/sample-document.pdf
Binary file not shown.
11 changes: 11 additions & 0 deletions website/docs/files.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,17 @@ async def serve(q: Q):

See `examples/file_stream.py` for a complete example.

## Rendering documents

Use `q.site.upload()` to upload document from your app to the Wave server (or see the following section for other ways for serving files). Use the returned paths in `ui.frame()` component.

```py
q.app.document_path, = await q.site.upload(['path/to/my/document.pdf'])
q.page['example'] = ui.form_card(box='1 1 7 7', items=[
ui.frame(path=document_path)
])
```

## Serving files directly from the Wave server

As an alternative to using the above `upload()` or `download()` mechanisms, you can make the Wave server (`waved`) directly serve the contents of one or more existing directories. If the Wave server and your app both have access to the directories on the file system, your app can simply create or copy files to the directories to make them accessible from web browsers.
Expand Down
10 changes: 10 additions & 0 deletions website/widgets/form/frame.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,16 @@ q.page['example'] = ui.form_card(box='1 1 7 7', items=[
])
```

## With document

The frame is also a preffered way for displaying documents. Simply provide a path to the PDF file.

```py
q.page['example'] = ui.form_card(box='1 1 7 7', items=[
ui.frame(path='/assets/examples/sample-document.pdf')
])
```

## With custom HTML

For cases when you want to build the embedded page yourself, you can use the `content` attribute that
Expand Down

0 comments on commit 293c837

Please sign in to comment.