Преглед на файлове

improved and explained the nginx_subpath demo

Rodja Trappe преди 2 години
родител
ревизия
2cd48a9df4
променени са 3 файла, в които са добавени 25 реда и са изтрити 6 реда
  1. 4 1
      examples/nginx_subpath/README.md
  2. 17 0
      examples/nginx_subpath/app/main.py
  3. 4 5
      examples/nginx_subpath/docker-compose.yml

+ 4 - 1
examples/nginx_subpath/README.md

@@ -12,4 +12,7 @@ Just run
 docker-compose up
 ```
 
-Then you can access http://localhost/nicegui.
+Then you can access http://localhost/nicegui/.
+Note the trailing / in the url.
+It is important.
+We welcome suggestion on how to make it optional.

+ 17 - 0
examples/nginx_subpath/app/main.py

@@ -0,0 +1,17 @@
+from nicegui import ui
+
+
+@ui.page('/subpage')
+def subpage():
+    ui.label('This is a subpage')
+
+
+@ui.page('/')
+def index():
+    with ui.card().classes('mx-auto px-24 pt-12 pb-24 items-center'):
+        ui.label('this demonstrates hosting of a NiceGUI app on a subpath').classes('text-h5')
+        ui.label('as you can see the entire app is available below /nicegui but the code here does not need to know that').classes('text-lg')
+        ui.link('navigate to a subpage', subpage).classes('text-lg')
+
+
+ui.run()

+ 4 - 5
examples/nginx_subpath/docker-compose.yml

@@ -2,12 +2,11 @@ version: "3.9"
 services:
   app:
     image: zauberzeug/nicegui:latest
-    ports:
-      - "3000:8080"
-
+    volumes:
+      - ./app:/app # mount local app directory
   proxy:
     image: nginx:1.16.0-alpine
     ports:
-      - "80:80"
+      - "80:80" # map internal port 80 to external port 80
     volumes:
-      - ./nginx.conf:/etc/nginx/nginx.conf
+      - ./nginx.conf:/etc/nginx/nginx.conf # use custom nginx config