Skip to content

Commit 9626d1e

Browse files
authored
docs: update README how to build and run (#24)
1 parent fadd9cc commit 9626d1e

File tree

1 file changed

+73
-0
lines changed

1 file changed

+73
-0
lines changed

README.md

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,79 @@ Stream data through multiple QRCodes
3131

3232
[Live demo](https://qrss.netlify.app/)
3333

34+
## Build & run
35+
36+
**1. Install Dependencies**
37+
38+
You need install [Node.js](https://nodejs.org) first.The project uses `pnpm` as its package manager. First, ensure you have `pnpm` installed:
39+
40+
```bash
41+
npm install -g pnpm
42+
```
43+
44+
Then, install the project dependencies:
45+
46+
```bash
47+
pnpm install
48+
```
49+
50+
**2. Build the Project**
51+
52+
Build the project using the command specified in the `package.json` and `netlify.toml`:
53+
54+
```bash
55+
pnpm run build
56+
```
57+
58+
This will generate the output in the `.output` directory.
59+
60+
Alternatively, if you want to run the development server to test changes:
61+
62+
```bash
63+
pnpm run dev
64+
```
65+
66+
**3. Serve the Project Locally**
67+
68+
if your target environment have `Node.js`, you can copy entire `.output` directory to where you want.You can preview this build using:
69+
70+
```bash
71+
node .output/server/index.mjs
72+
```
73+
74+
if your target environment don't have `Node.js`, you cat just host those static files.
75+
76+
```bash
77+
cd .output/public
78+
python -m http.server
79+
```
80+
81+
You will usually encounter the following errors.
82+
83+
```
84+
Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "text/plain". Strict MIME type checking is enforced for module scripts per HTML spec.
85+
```
86+
87+
you need a custom web server, Run in the `.output/public` directory:
88+
89+
```python
90+
# python custom_http_server.py
91+
from http.server import SimpleHTTPRequestHandler, HTTPServer
92+
93+
class CustomHandler(SimpleHTTPRequestHandler):
94+
def end_headers(self):
95+
self.extensions_map.update({
96+
".js": "application/javascript",
97+
})
98+
super().end_headers()
99+
100+
ADDR = '0.0.0.0'
101+
PORT = 8000
102+
with HTTPServer((ADDR, PORT), CustomHandler) as httpd:
103+
print(f"Serving on http://{ADDR}:{PORT}")
104+
httpd.serve_forever()
105+
```
106+
34107
## Sub-packages
35108

36109
- [QiFi CLI](./packages/cli) - CLI for streaming QR code file transmission

0 commit comments

Comments
 (0)