Note: To access all shared projects, get information about environment setup, and view other guides, please visit Explore-In-HMOS-Wearable Index.
This project is an educational project designed to demonstrate how to implement a web server on Huawei wearable devices using socket connections. This codelab serves as a foundational tutorial for developers who want to understand network communication capabilities on HarmonyOS wearables.
When launched, the application starts a local HTTP server on the wearable device. The server logs all incoming requests to the device screen and responds with an echo containing all the request parameters and data it received.
The key learning objective is to understand socket-based web server implementation on wearable platforms, providing the foundation for more complex networked wearable applications.
Ideal for learning web server fundamentals on wearable devices, prototyping IoT applications, understanding HarmonyOS networking capabilities, and serving as a foundation for building more complex networked wearable applications. This codelab demonstrates that even constrained wearable devices can function as capable network endpoints.
- Languages: ArkTS, ArkUI
- Frameworks: HarmonyOS SDK 5.0.2(14)
- Tools: DevEco Studio Vers 5.1.0.820
- Libraries: @kit.ArkUI, @kit.NetworkKit
To test the web server functionality on real devices, follow these steps:
- Server and client must be connected same Wi-Fi network
- HTTP client (browser, curl, or Postman) for testing
-
Launch the app on the watch - the web server will start automatically
-
Test the server from your local machine:
# Simple GET request curl http://localhost:6060 # POST request with data curl -X POST http://localhost:6060/test -d "key=value&name=example" # GET request with query parameters curl http://localhost:6060/api?param1=hello¶m2=world
-
Observe the results:
- Watch the wearable screen to see logged request details
- Check the HTTP response containing echoed request parameters
The host computer acts as a bridge, forwarding HTTP requests from your local machine to the watch's web server through port mapping.
entry/src/main/ets/
├───entryability
│ EntryAbility.ets
├───entrybackupability
│ EntryBackupAbility.ets
├───lib
│ http_server.ts
├───pages
│ Index.ets
└───
- Huawei Watch 5
Wearable Web Server is distributed under the terms of the MIT License. See the license for more information.
