Golang + HTMX - Creating a Go webserver / HTMX Integration / Template Fragments
BugBytes
View ChannelAbout
On this channel, we create tutorials and videos primarily about web development, data analytics and data science. We'll focus on implementations using primarily Python and JavaScript, occasionally diving into other languages. As the channel progresses, we will also touch on concepts such as DevOps, containerization, cloud computing (AWS) and machine learning/AI. If you can spare any change, please consider buying me a coffee to help keep me motivated to write tutorials, make videos and write blog posts! It would be greatly appreciated: https://ko-fi.com/bugbytes Blog: https://www.bugbytes.io/posts/ Github: https://github.com/bugbytes-io
Latest Posts
Video Description
โ๏ธ ๐๐๐ ๐บ๐ฒ ๐ฎ ๐ฐ๐ผ๐ณ๐ณ๐ฒ๐ฒ: To support the channel and encourage new videos, please consider buying me a coffee here: https://ko-fi.com/bugbytes Playlist โถ๏ธ: https://www.youtube.com/playlist?list=PL-2EBeDYMIbQRWxVjUwE4uVXKr2lnquD- โญTop resource to learn Python - https://datacamp.pxf.io/ranBod โญ In this video, we'll explore how to integrate HTMX with the Go programming language on the server. We'll cover: - how to setup a webserver with the Go net/http package - how to define routes and handlers with the HandleFunc function - how to return HTML templates with the html/template package - using HTMX to submit form data to the server - swapping HTML responses into the document from our Golang handlers - using template fragments to return blocks of HTML from a parent template Final code can be found on this Github repository: https://github.com/bugbytes-io/htmx-go-demo Playlist โถ๏ธ: https://www.youtube.com/playlist?list=PL-2EBeDYMIbQRWxVjUwE4uVXKr2lnquD- ๐ ๐๐ต๐ฎ๐ฝ๐๐ฒ๐ฟ๐: 00:00 Intro 01:32 Creating a web server in Golang 03:28 Defining server URL and handler function with http.HandleFunc 06:31 Rendering template from Golang functions 09:40 Adding Context Data to templates 11:21 Displaying server data in templates 13:44 Styling list with Bootstrap 5 15:34 Submitting form with HTMX hx-post attribute 19:44 Extract Submitted Data from POST request in handler function 21:03 Returning HTML from Golang handler function 24:03 Using hx-target to swap content into targeted DOM element 26:51 Displaying feedback during request with hx-indicator 30:37 Template Fragments in Golang ๐ฆ๐ผ๐ฐ๐ถ๐ฎ๐น ๐ ๐ฒ๐ฑ๐ถ๐ฎ: ๐ Blog: https://bugbytes.io/posts/ ๐พ Github: https://github.com/bugbytes-io/htmx-go-demo ๐ ๐๐๐ฟ๐๐ต๐ฒ๐ฟ ๐ฟ๐ฒ๐ฎ๐ฑ๐ถ๐ป๐ด ๐ฎ๐ป๐ฑ ๐ถ๐ป๐ณ๐ผ๐ฟ๐บ๐ฎ๐๐ถ๐ผ๐ป: Install Go: https://go.dev/doc/install Go โHello Worldโ: https://gobyexample.com/hello-world Go net/http package: https://pkg.go.dev/net/http Go html/template package: https://pkg.go.dev/html/template Go templates: https://golangforall.com/en/post/templates.html HTMX Install: https://htmx.org/docs/#installing HTMX Swap Methods: https://htmx.org/docs/#swapping Bootstrap 5 CDN: https://getbootstrap.com/docs/5.3/getting-started/introduction/#cdn-links Bootstrap Spinner: https://getbootstrap.com/docs/5.2/components/spinners/#buttons #golang #htmx #webdevelopment
Transform Your Space Today
AI-recommended products based on this video

Generic Collapsible Washing up Bowl Folding Dish Basin Bucket Portable Dish Pan Foldable Wash Basin for Camping Beach RV Backpacking, Green 38x23.5x11.5cm

Koolmox Koolmox Canvas Grocery Bag, 6-Pack 22'' Large Bags with Reinforced Handles, 12 Oz Heavy Duty Reusable Washable Grocery Shopping Bags Plain Bags for Teacher Paint Embroidery Draw DIY Art Craft Totes
![Command Medium Picture Hanging Strips [Removable]: 12 Pairs (White)](https://m.media-amazon.com/images/I/61IChX1hbML._AC_UL960_FMwebp_QL65_.jpg)
Command Medium Picture Hanging Strips [Removable]: 12 Pairs (White)

Camping String Lights Outdoor, 6 in 1 Outdoor Waterproof Solar/USB Rechargeable Retractable Portable Stowable String Light with 8 Modes (42ft), Tent Lights for Camping, Hiking, Yard, RV (Multicolor)

LEGO Botanicals Tiny Plants - Artificial, Fake Indoor Plant Building Set for Home, Kitchen, Desk Decoration, Adults Ages 18+ - Gift for Graduation - 10329

LEGO LEGO Botanicals Happy Plants Building Toy for Kids, Girls, and Boys 9+ - Playroom Decor for Desk or Shelf - Birthday Gift Idea for Young Gardeners - Artificial Indoor Plants for Play & Display - 10349

LEGO Icons Bonsai Tree Building Set - Artificial Bonsai Tree Plants for Home Decor, Adults Ages 18+ - Faux, Fake Plants for Table, Desk, Office - Birthday Gift for Men & Women - 10281




