Skip to content

Commit

Permalink
added python demo section
Browse files Browse the repository at this point in the history
  • Loading branch information
codetricity committed Nov 6, 2024
1 parent 106f90c commit 126779c
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 0 deletions.
Binary file added docs/images/python/home_screen.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
44 changes: 44 additions & 0 deletions docs/python.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Python Demo with Flask and Jinja

![home screen](images/python/home_screen.png)

An example Python Flask server is in the [python_server.py](https://github.com/theta360developers/oppkey-ricoh-viewer-demo-basic/blob/main/python_server.py)
file.

Python is an alternative to JavaScript on the backend. If your
backend infrascture uses JavaScript, you do not need to use Python.

The backend can be built with any language. Python is used to
illustrate a simple example of using any backend framework.

To run the Python demo, follow the step below.

```text
python -m venv venv
source venv/bin/activate
pip install -r requirements.txt
python python_server.py
```

You will then need to open a web browser at the URL provided.

```text
python python_server.py
* Serving Flask app 'python_server'
* Debug mode: on
WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
* Running on http://127.0.0.1:3000
```

## viewer token creation

```python
# Function to create a JWT token for the viewer API
def create_token():
payload = {"client_id": CLIENT_ID}
token = jwt.encode(payload, PRIVATE_KEY, algorithm="RS256")
# Decode to UTF-8 if necessary

return token if isinstance(token, str) else token.decode("utf-8")
```
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ nav:
- Features: features.md
- Structure: structure.md
- Contact: contact.md
- Python Flask: python.md

plugins:
- search
Expand Down

0 comments on commit 126779c

Please sign in to comment.