From 2c7939bb06eb4b6a84aef292ba0aec5f2d0cf0e0 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Fri, 16 Feb 2024 10:04:14 -0600 Subject: [PATCH 1/6] Use circup to install adafruit_httpserver The bundled httpserver was old and its mpy format was not compatible with circuitpython 9 --- scripts/deploy.sh | 8 ++++++-- src/lib/adafruit_httpserver/__init__.mpy | Bin 150 -> 0 bytes src/lib/adafruit_httpserver/headers.mpy | Bin 891 -> 0 bytes src/lib/adafruit_httpserver/methods.mpy | Bin 190 -> 0 bytes src/lib/adafruit_httpserver/mime_type.mpy | Bin 2639 -> 0 bytes src/lib/adafruit_httpserver/request.mpy | Bin 1038 -> 0 bytes src/lib/adafruit_httpserver/response.mpy | Bin 1909 -> 0 bytes src/lib/adafruit_httpserver/route.mpy | Bin 338 -> 0 bytes src/lib/adafruit_httpserver/server.mpy | Bin 2243 -> 0 bytes src/lib/adafruit_httpserver/status.mpy | Bin 486 -> 0 bytes 10 files changed, 6 insertions(+), 2 deletions(-) delete mode 100755 src/lib/adafruit_httpserver/__init__.mpy delete mode 100755 src/lib/adafruit_httpserver/headers.mpy delete mode 100755 src/lib/adafruit_httpserver/methods.mpy delete mode 100755 src/lib/adafruit_httpserver/mime_type.mpy delete mode 100755 src/lib/adafruit_httpserver/request.mpy delete mode 100755 src/lib/adafruit_httpserver/response.mpy delete mode 100755 src/lib/adafruit_httpserver/route.mpy delete mode 100755 src/lib/adafruit_httpserver/server.mpy delete mode 100755 src/lib/adafruit_httpserver/status.mpy diff --git a/scripts/deploy.sh b/scripts/deploy.sh index 393f729..fc0db70 100755 --- a/scripts/deploy.sh +++ b/scripts/deploy.sh @@ -24,8 +24,12 @@ fi echo "Found device at $device_path" echo 'Copying application code...' -rsync --verbose --recursive --delete --checksum \ +rsync --verbose --recursive --delete --checksum -@2 \ --include '/._*' --exclude '/.*' \ - --exclude '/boot_out.txt' --exclude '/settings.toml' \ + --exclude '/boot_out.txt' --exclude '/settings.toml' --exclude '/lib' \ "$project_directory/src/" "$device_path" echo 'Finished copying application code' + +echo 'Installing libraries with circup' +circup install -a +echo 'Finished installing libraries with circup' diff --git a/src/lib/adafruit_httpserver/__init__.mpy b/src/lib/adafruit_httpserver/__init__.mpy deleted file mode 100755 index 4a3525c0276d0f93f97b1c1e800196748d50837b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 150 zcmZ=}Ws+A&U=U(pw@XY(Oe-qQEQ!x3DJdvUEhlIWcGzh6N2yhwc z8S5E{iN(hQrHeE3^Wx)`8N>wQFcLwmSmJB=_Tjq>cb4z ecZAvEoLQ6%v@M{rBm-!QM@UFOFxXB#pe_K}&@x8= diff --git a/src/lib/adafruit_httpserver/headers.mpy b/src/lib/adafruit_httpserver/headers.mpy deleted file mode 100755 index 1e1681e6ebca05f1de515aa192bced5a668c623b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 891 zcmah`T~E_c7=GGPyD{iG+8jWdFfj207tsSQUJyeRb$rA)88bvoSGSH8VOzFhAV@qj z-jEpn0tx(q&0DYVe;Dum6`p>GAzs*%=A7hxzRq(V%i?(YlbIQTGG|xpYHQc^teWRF z+fM7f)0(b1cExG6?=<&IrP8(WrxoN(FfF#=mOZV%u-n{rro^!UZ@=l*H%*xc{=dF7 zh*v3G|GCh|)|UjlDNtx6S17#5g>thZ5%OgSpUv335dWgF@p-r8rrop?t`gsa4=D^2 z5KSVunx7I@XF!k&4gx_jIEVztl+UZQk6??+1ZVUL!3k9e7HNziN#g`2?I%dk1c6Qm z2n;$%Ml7q`sC%|sZ(9~s3C4J&WG8kiXh_Ly<{5fVM3%uh6?+D%ScZj^|mk3$YOf*(XWqX0CK1A8}}&+ z>_Hk`T`^D$5qXZyik&qdbQG)GJC0g$s`l=-7c!0&HWx9DLx!(@!BCXFQ4Ljv&8IPh zl7R@YmBj_%Ok%lz02~(pKF}eYNNgp2gGcB5lfMmRg`k&& zUr0h>&;M7$-h_rlfxYBj$slh$iZjcFcmo@gDv~lQ`bOb(*P?C)YcncLnXSVwpsUN_ zxX2%d^JJWsI5i=&4Ni?_tFQk|y$Kb%%q-r~W?(B{wp~f7FeLVt&);$9C`@fqF*Z|k_!oPbOtHnbN2W1b9Dyl I1lr6103XaL82|tP diff --git a/src/lib/adafruit_httpserver/mime_type.mpy b/src/lib/adafruit_httpserver/mime_type.mpy deleted file mode 100755 index 42644490dbabe60719d4ffc688f35d3fc8b7607d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2639 zcmb7G%~IP&9G9UfY0?DYI1bH6q1{5764^5jlU!qLV@xnsu)r?U8CXjzvqaKrw2N`L zG`;uG&h!C#?x}r*zEYo{yV91 zQWQ;4RQ0isj@a7}Rl>K&@8&eCrs;aO(`{LtTc0TxUfWvX7w!5VGlkioZyqnNu82SJ zxw^Wt+=~CpQ%tQ2K9R1*DAq~T_?dGF&6$?ApxrBLWqr1+-Peoo%)z7zprWCZy{SENB4BkFe z$&IlqmD`<7y%@@XKG7=vG~X`I7u;20%vWttmioP>3GSu14;E8wsRbfq z6}{I^BWB41@P)E!4^`46JfkvT&)nw&cS*pigsJiLEIyv3v0aw%R(LD#^FJPpOo0IM>?;Z7esmQFby zf^U_8D?L$oe+PUg@nOdVYqBRV4i~iFYERb-<%e!W{3928=qP|bdTl=~(7P}UJ#0gU zNl={{aD>lE{N#InV4=+eiK_f!m(8a8j*bFg)vIs$+ z7PFG6F}lDZz4Ja-qYHV`rYCt@pT_yNvuYv_5~5)0doGE5$f&{Fk8R`-`^-lHs|cGg zA~vEF2V>u>C<%RZ)sasPF)K1UMK+_QtQdu7qcxGao@K{^Sxl~y$i&BXL@04t1=}Q` zx02TvdMI#UlyA`~oIr#3`2HsN?| zd<#$o2b4k2L(v*<9j#tfB9LMlcUHBl5=MyfhQ{kdD<5G%xdn9S2||oM{s?{11UjEp zm>-6474h-rGLM*> zAL7*D>wGI&6*?KmUC%9`P$2dj{wyKG^&r>2GEBx})Da)CV$R;Fi3Iynn*a~@YpX;SAC}Pyzt|GN&Ee|_Rrr%ZBR^q|NT`g+YipV= Jo<;F0{tNu&QQ-gp diff --git a/src/lib/adafruit_httpserver/request.mpy b/src/lib/adafruit_httpserver/request.mpy deleted file mode 100755 index 46ebd255567707c5b6ed96f5633b474b5266cfd5..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1038 zcmYjQ-*4Mg6h7C9n~){LZXMVCA?lH>+d|Za5Cxb9L?vTci>ihu8$(QvW8acMVte*2 zQ=WPw`qBv@A^1a_W^3WG&C13z65?gs6aPT}0CpYq&-x*N~D z1(EBzsc*U4Euu9EaXjpPkKJV#-`~a_S#rAddOfv}%6?sPpnLi4wE#RL-R;REFx`=A{(~dW>IO3JItF8F?=-v zcSKlxSqjs;s|fD(1i4(TZj`ZZV%K8@=bK}5lwHli82@5SHqXhZVgUN#%jgD5{wURp zYF$<78)}g~G{!#6t=IQvzb$suhp~s#Ai}f^vJjGCwvtAh?|}@WC^)X|V3%}rD39c5 z!#2Ajnu>dv5bWkS77K}dF2w$CkJ)HJiq_~7?1}JeE*v15qq`o~JfgcqYqu;MAUs3n z&ycf&FuoJJ(m#=lAihc0FI~E^SiYI67eD+8`o1C=wq;?1uomz8%DmBTVT)+GX}Z|+ z2EHP@`UCAusX^sMDM}~d{S@0D`%?*8ds4m(zLa=WK-sXb#5Gk+s&7ftjbp|tg3Kl5-z?hP1BQG=O9>~ALO~mTb0Vm75-kJQN`c@ z_L9k@H~ShL)zB@=CTat#>$ZixnVL1~h~8*p^|icfYDpC4W~ixxKQ+^<8Ne26&YtIa z+F}u&)>7PQ|I}9^6$3FS(g-JFiCAyrU73&2PBD}IoTWu1*i4}UI`XGbrN6}0j+xQl zJ*_ZvxIaj9quO!lZhlW#oZ;z%VrA{>XX~k@D@!+Tu|CC3Y}h6iqT6Kag94Hy&uO(;eY`G>J_*wH$2I}ACCi{TPz@L?J_(S zxQ`B>my-1G|Eyv8L{_@q8)18$UJ3+(w{{X_@Eqnj~ diff --git a/src/lib/adafruit_httpserver/response.mpy b/src/lib/adafruit_httpserver/response.mpy deleted file mode 100755 index 3e8ff22d70dcd65b3fd666ad728b91213cf61b11..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1909 zcmaJ?%}*Ow5PxrN2jke`d3RYHAjOF><{JlGM`@*q7(09<0SuAsd~zxN~JbZB@UIU9(t6P*v(`S9)(|-^_33 zH#2X@!L|55>+WtxH5W1qnZ?pdPM4Q-y{OUBDlPSus8&=JjrJDT=jP@DE#2X3@%D5$ ze7=ZA#t|cAqNwLoC6g!4crL3G*Ng&N;!3R)^R(06T-A+?u63;>@x)LNg1rq?z`Xs!PjWsvi+w z)n7Ha5l+I%EW)3L{c+s$q>+XEgMN5e?VQdUHcmfjyvh7u5<2+EiM*&mLK3k_sL@+1 zxF;^l{o!yjNr-8%?`-ec$xg@g0Fsb5ne61I2e8yAYgAc~4-gQ9EjcHl4I<{01-jO| zq!;qU-rINPbJS^@9r|^3xo*uAEq9w{MttiX=4hgyYk4ebmMbG+cB3P2D zF6P&DszD&mhwa}zV%U$o_3R_&3cl}`gTWvw8@|&#%2fDM5e`_a#A+CiE7R{H!`A}x zO-o+OHbpcVMX_U`+>Bt*Z5cjaR#kMW=oV$$us2Ioh62@~+MXM}6BaPKFlqR@<-?kl zGx-vvecc4711yBT@YZ?Yc})IdxVNRAX>)^P{J_T2~M4^=~3G*fPEUURT3U%2toodpA|?dJ(-YGAEu&Q+Ef#9 zNL3V?HT#61VUQZa$#|U^=hJ|lU=YMy)t#eUJ+l}^@?{Z)xxJTLgxtCN9w4z`Y(I~3 z`@6AU?`;vg$F;v}h#^BbEr^hw0}orGn<^$sg1(BHwv$;K1m1j@z&urM=t~Wn8$g*E z?J+w-^QKA}MO&n$o`iWAI#xSz_`?w|oC#GQ;s z{Q+A9Qy$HhNo_J>i+fmE#1@2|7{|&xhS))BD+xQK36tYIS_W#PpQ5xOdJVxVcsBv* zl;NvOW-*|3&Z`US9_{4R!SwOp%4q%rHvJ}>kDGscgnI|-+1IQlG}7G`xPAUo=%&9f zZ~+k29w4#Tt(5R<)W9?{`N8vZ|7MAA! z)tf*o>Ei#>^g`qKL`uFiF*6>QBjHHo0T$6l6hXGl*<^?&U^u-kqPv?>Jo|EJ|6cOibx2H0H8I4r zWt!qks;bMyjJ_nzuPg#_vX;9||0iP)KKTYW9%Qz zh+Gf?9B@^R;6DMCAvz4fAy`FvxDME?661h0m(_#w_TZYwHP3lmc`uLL$JtMz5O8uX zUIP&ZAVY@Li1*tKI}8v9`y~_$b)s_e=T~u#O=iIXz<{cN!4t*lDeLEEx|XHZJ!AF% zJ8!qEnfwZEd%M?5nJk^pWS1YNe&qc19`^g0P$&@ixU01bu@}`)c6hNs3up!T74z@RX3T+G3`-DHZY+l0v8}u=5Td?s*?w!{V eL^7L9?zKCvn}tx>{9$PGo;iD9awv+s%GKY^$R&{g diff --git a/src/lib/adafruit_httpserver/route.mpy b/src/lib/adafruit_httpserver/route.mpy deleted file mode 100755 index 9eb6da87e766b88edb831ed4485b7ba3f318d275..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 338 zcmX|6%Syvg6g(#}-d1Y3N$NE=iUAR95rr7UjZhFD8^K35y15DMmAH_m>8&6tB<=+N z!XHTe8-K!YFipkP49uLFIY*kZ?&dBvfgD8r=q?@KOCC#^j70h<(%p10mSQJ)3d1mg zoHoyb;No1!c+l^lqd!z^w5l?^2|S=pKGm^5+7rs}H6UW4^ED6=5rV(|WblfxqSL2qKk2*vt*fg>w@H--r5%$Pmx=MT_n7IdRVtPEM11zO+(dR3J{`1>M;6Ow z)mBTbwg}5E8#>i%dW#L7)0(=L^z9p?Yn`TcF*YLN?O)kq$4tF;iO?k8hhtd8AQ6hL zWLei+AQe1)2i{^n&@YA1D-ksLFgIkCmoT~jJLKn1&Mlr{g?#qxnKLW-V!p(3`O@O) zeD3VI5(Ews!_f5Yn9j4j&I${q((-9S8+sk0gxl`QbVIDOqN7|PZ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httpserver/status.mpy deleted file mode 100755 index 0dc04dd8b0526cbb4e7d59a8d363ea48ddb106de..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 486 zcmYk3?@QZ27{{OF3|&-evc|KttHu;T!5<~mz1XX0O|f(&Ha&fN4b4dfZ8W)#NmocG zdoku8Q}^Ha-*_#933uG_{XCzC`_WM3Epz&*Xh7~u7=_o#=!Vk)=l3Z~zOm#eM;a2YKp15h>3r&M%cQ&|w1u z))0o04H$G=!cewl3>6#URZ7_drNUb3RSnRUEZ=i>;AK|)(2pbbSFD_U=Yj+LMkw0O zLs`i-peh+aW(7rz&vIW9FnxE%-SK4Kw8j%_Zy3^8rhK5^Zx$ecpBsorC#&eSaS=M&oWFTFESP@k*3Dv8`~dBhF8 yldrVv23KxC-5~G-dR(h@`ZA;|r(t9U>|w-Gp02lsoF&8X*6c1m&~%d|PTm0Q7IvWk From e9442e94571f54b23b3d424e9dbcea4ecfede215 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Fri, 16 Feb 2024 10:04:38 -0600 Subject: [PATCH 2/6] Update to newest adafruit_httpserver; make content dynamic Now it'll name the specific device and version in the returned (text/plain) content. --- src/code.py | 18 +++++++++++++++--- src/public_html/index.html | 3 --- 2 files changed, 15 insertions(+), 6 deletions(-) delete mode 100644 src/public_html/index.html diff --git a/src/code.py b/src/code.py index 47f3341..8caa805 100644 --- a/src/code.py +++ b/src/code.py @@ -7,7 +7,17 @@ import supervisor import wifi -from adafruit_httpserver.server import HTTPServer +from adafruit_httpserver.server import Server as HTTPServer +from adafruit_httpserver.response import Response + + +def index(request): + u = os.uname() + return Response( + request, + content_type="text/plain", + body=f"Hello from {u.machine} running {u.version}!\n", + ) def main() -> None: @@ -24,7 +34,8 @@ def main() -> None: host = str(wifi.radio.ipv4_address) pool = socketpool.SocketPool(wifi.radio) http_server = HTTPServer(pool) - http_server.start(host, port=80, root_path="public_html") + http_server.route("/")(index) + http_server.start(host, port=80) ssl_context = ssl.create_default_context() # The Pico is the server and does not require a certificate from the client, so disable @@ -35,7 +46,8 @@ def main() -> None: ) tls_pool = TLSServerSocketPool(pool, ssl_context) https_server = HTTPServer(tls_pool) - https_server.start(host, port=443, root_path="public_html") + https_server.route("/")(index) + https_server.start(host, port=443) print() print("The web server is listening on:") diff --git a/src/public_html/index.html b/src/public_html/index.html deleted file mode 100644 index 73fb978..0000000 --- a/src/public_html/index.html +++ /dev/null @@ -1,3 +0,0 @@ - -Hello world · Raspberry Pi Pico W -

Hello world from Raspberry Pi Pico W!

From 1fe1708b86d01c468e2d4699f5b368d1e894d045 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Sun, 18 Feb 2024 10:34:08 -0600 Subject: [PATCH 3/6] Apply suggestions from code review Co-authored-by: James Ide --- scripts/deploy.sh | 2 +- src/code.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/deploy.sh b/scripts/deploy.sh index fc0db70..feef265 100755 --- a/scripts/deploy.sh +++ b/scripts/deploy.sh @@ -31,5 +31,5 @@ rsync --verbose --recursive --delete --checksum -@2 \ echo 'Finished copying application code' echo 'Installing libraries with circup' -circup install -a +circup install -all echo 'Finished installing libraries with circup' diff --git a/src/code.py b/src/code.py index 8caa805..dc035ae 100644 --- a/src/code.py +++ b/src/code.py @@ -16,7 +16,7 @@ def index(request): return Response( request, content_type="text/plain", - body=f"Hello from {u.machine} running {u.version}!\n", + body=f"Hello from {u.machine} running CircuitPython {u.version}!\n", ) From d851c9a74a43522f9541f204552dffd848670a52 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Tue, 20 Feb 2024 09:16:05 -0600 Subject: [PATCH 4/6] Use long option names with rsync --- scripts/deploy.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/deploy.sh b/scripts/deploy.sh index feef265..8242a23 100755 --- a/scripts/deploy.sh +++ b/scripts/deploy.sh @@ -24,7 +24,7 @@ fi echo "Found device at $device_path" echo 'Copying application code...' -rsync --verbose --recursive --delete --checksum -@2 \ +rsync --verbose --recursive --delete --checksum --times --modify-window=1 \ --include '/._*' --exclude '/.*' \ --exclude '/boot_out.txt' --exclude '/settings.toml' --exclude '/lib' \ "$project_directory/src/" "$device_path" From 30488c93e177ea7f7543c3638a88018e9c33b9e9 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Tue, 20 Feb 2024 09:16:26 -0600 Subject: [PATCH 5/6] fix circup invocation to use double dash --- scripts/deploy.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/deploy.sh b/scripts/deploy.sh index 8242a23..5201066 100755 --- a/scripts/deploy.sh +++ b/scripts/deploy.sh @@ -31,5 +31,5 @@ rsync --verbose --recursive --delete --checksum --times --modify-window=1 \ echo 'Finished copying application code' echo 'Installing libraries with circup' -circup install -all +circup install --all echo 'Finished installing libraries with circup' From dc6543963282f7ca1805d1d4f764216401aa7035 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Tue, 20 Feb 2024 09:21:31 -0600 Subject: [PATCH 6/6] Perform circup installation from a requirements file .. generated by "circup freeze" --- circup_requirements.txt | 1 + scripts/deploy.sh | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 circup_requirements.txt diff --git a/circup_requirements.txt b/circup_requirements.txt new file mode 100644 index 0000000..33cdda0 --- /dev/null +++ b/circup_requirements.txt @@ -0,0 +1 @@ +adafruit_requests==2.0.5 diff --git a/scripts/deploy.sh b/scripts/deploy.sh index 5201066..034e3d0 100755 --- a/scripts/deploy.sh +++ b/scripts/deploy.sh @@ -31,5 +31,5 @@ rsync --verbose --recursive --delete --checksum --times --modify-window=1 \ echo 'Finished copying application code' echo 'Installing libraries with circup' -circup install --all +circup install --requirement circup_requirements.txt echo 'Finished installing libraries with circup'