File tree Expand file tree Collapse file tree 11 files changed +94
-0
lines changed Expand file tree Collapse file tree 11 files changed +94
-0
lines changed Original file line number Diff line number Diff line change @@ -133,7 +133,9 @@ function decode_result() {
133133
134134function component() {
135135 local REQUEST_PATH
136+ local REQUEST_METHOD
136137 REQUEST_PATH=" $1 "
138+ REQUEST_METHOD=" GET"
137139 route_script=` matchRoute " $REQUEST_PATH " `
138140 INTERNAL_REQUEST=true
139141 result=$( source " pages/${route_script} " )
Original file line number Diff line number Diff line change 1+ data /
2+ pubsub /
3+ uploads /
Original file line number Diff line number Diff line change 1+ FROM ubuntu
2+
3+ RUN apt-get update && apt-get install ucspi-tcp
4+
5+ EXPOSE 3000
6+
7+ COPY . /app
8+
9+ CMD [ "/app/start.sh" ]
Original file line number Diff line number Diff line change 1+ PROJECT_NAME=" Counter"
Original file line number Diff line number Diff line change 1+ ../../core.sh
Original file line number Diff line number Diff line change 1+
2+ if [[ ! -f data/count ]]; then
3+ echo " 0" > data/count
4+ fi
5+
6+ COUNT=$( cat data/count)
7+
8+ if [[ " $REQUEST_METHOD " == " POST" ]]; then
9+ # increment the count
10+ COUNT=$(( COUNT + 1 ))
11+ echo " $COUNT " > data/count
12+ fi
13+
14+ htmx_page << EOF
15+ <p id="count" hx-swap-oob="true">$COUNT </p>
16+ EOF
Original file line number Diff line number Diff line change 1+
2+ source config.sh
3+
4+ htmx_page << EOF
5+ <h1>${PROJECT_NAME} </h1>
6+ <button hx-post="/count" hx-swap="none">Count</button>
7+ <button hx-post="/reset" hx-swap="none">Reset</button>
8+ $( component ' /count' )
9+ EOF
Original file line number Diff line number Diff line change 1+ if [[ " $REQUEST_METHOD " != " POST" ]]; then
2+ # only allow POST to this endpoint
3+ return $( status_code 405)
4+ fi
5+
6+ echo " 0" > data/count
7+
8+ component ' /count'
Original file line number Diff line number Diff line change 1+ # allow-uploads
2+
3+ echo " <pre>"
4+ printf " %s\n" " ${FILE_UPLOADS[@]@ K} "
5+ printf " %s\n" " ${FILE_UPLOAD_NAMES[@]@ K} "
6+ printf " %s\n" " ${FILE_UPLOAD_TYPES[@]@ K} "
7+ echo " </pre>"
Original file line number Diff line number Diff line change 1+ ../../start.sh
You can’t perform that action at this time.
0 commit comments