Skip to content

Commit

Permalink
name change, project restructure
Browse files Browse the repository at this point in the history
  • Loading branch information
CheeseCake87 committed Dec 4, 2024
1 parent 7e70fe0 commit 830eb4d
Show file tree
Hide file tree
Showing 34 changed files with 434 additions and 528 deletions.
50 changes: 19 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
# 🚚 vite-transporter
# flask-vite-transporter 🚚

**_Transport Vite apps._**
Transport Vite apps to Flask (or Quart)

```bash
pip install vite-transporter
pip install flask-vite-transporter
```

**Currently compatible with:**

- Flask
- Quart

**Note (Flask/Quart):** When including credentials in fetch requests in the vite app.
You must visit the serve app first to set the credentials.

Expand All @@ -30,11 +25,11 @@ apps listed in the `vite_app_dirs` list to the serving app listed in the `serve_
`pyproject.toml`:

```toml
[tool.vite_transporter]
[tool.flask_vite_transporter]
npm_exec = "npm"
npx_exec = "npx"
serve_app = "app_flask_demo"
vite_apps = ["app_vite_demo"]
serve_app = "app_flask"
vite_apps = ["frontend"]
```

The compiling of the Vite apps requires the `npx` and `npm` be
Expand Down Expand Up @@ -115,8 +110,8 @@ These mode values are accessible via `import.meta.env.MODE` in the Vite app.

## Working with vite-transporter using Flask / Quart

vite-transporter creates a couple of Flask / Quart context processors that match the Vite apps
to a Flask / Quart template.
flask-vite-transporter creates a couple of Flask / Quart context processors
that match the Vite apps to a Flask / Quart template.

### The context processors

Expand Down Expand Up @@ -152,7 +147,7 @@ vt_body(
```python
from flask import Flask, render_template

from vite_transporter.flask import ViteTransporter
from flask_vite_transporter import ViteTransporter


def create_app():
Expand All @@ -171,12 +166,12 @@ def create_app():
```python
from quart import Quart, render_template

from vite_transporter.quart import ViteTransporter
from flask_vite_transporter.quart import QuartViteTransporter


def create_app():
app = Quart(__name__)
ViteTransporter(app)
QuartViteTransporter(app)

@app.route("/")
async def index():
Expand Down Expand Up @@ -206,33 +201,26 @@ Installing the development requirements will install `pyqwe`:
pip install -r requirements/tests.txt
```

Use `pyqwe` to install the local version of vite-transporter:
Use `pyqwe` to install the local version of flask-vite-transporter:

```bash
pyqwe install
```

The `serve_app` under `tool.vite_transporter` is currently set to use the Flask demo app.

We will run this in terminal 1:

```bash
pyqwe flask
```

You should be able to visit the Flask app from the link in the terminal, and see the current Vite app.

Next, we will run the Vite app in terminal 2:
The `serve_app` under `tool.flask_vite_transporter` is currently set to use
the Flask demo app.

```bash
pyqwe vite
pyqwe flask_plus_vite
```

Visit the vite app from the link in the terminal. Change something, save, then in terminal 3 run:
You should be able to visit the Flask app and the Vite app from the link in
the terminal. Change something in the Vite app, save, then in a separate
terminal run:

```bash
vt pack transport
```

The Vite app will be compiled, and the files will be moved to the Flask app.
Visiting the Flask app from the link in terminal 1 should show the changes.
Visiting the Flask app from the link in the terminal should show the changes.
2 changes: 1 addition & 1 deletion app_flask/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from dotenv import load_dotenv
from flask import Flask, render_template, session

from vite_transporter.flask import ViteTransporter
from flask_vite_transporter import ViteTransporter

load_dotenv()

Expand Down
1 change: 1 addition & 0 deletions app_flask/vite/frontend/index-9ef22729.js

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion app_flask/vite/frontend/index-cfd6b250.css

This file was deleted.

1 change: 1 addition & 0 deletions app_flask/vite/frontend/index-f465f2f2.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion app_quart/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from dotenv import load_dotenv
from quart import Quart, render_template, session

from vite_transporter.quart import ViteTransporter
from flask_vite_transporter.quart import ViteTransporter

load_dotenv()

Expand Down
2 changes: 1 addition & 1 deletion frontend/Index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export default function Index() {

return (
<div class={'container'}>
<h1>🚚 Vite-Transporter</h1>
<h1>Flask-Vite-Transporter 🚚</h1>
<p class={'pt-2'}>Image Asset Example</p>
<p>👇</p>
<img width={'100'} src={ili} alt={'ili'}/>
Expand Down
Loading

0 comments on commit 830eb4d

Please sign in to comment.