Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/uproid/example-webapp-docker
An example of creating a web application server-side using webapp in Dart on Docker.
https://github.com/uproid/example-webapp-docker
dart docker pubdev webapp
Last synced: 3 months ago
JSON representation
An example of creating a web application server-side using webapp in Dart on Docker.
- Host: GitHub
- URL: https://github.com/uproid/example-webapp-docker
- Owner: uproid
- Created: 2024-09-05T15:50:26.000Z (5 months ago)
- Default Branch: master
- Last Pushed: 2024-09-25T20:26:04.000Z (4 months ago)
- Last Synced: 2024-09-30T11:04:22.684Z (4 months ago)
- Topics: dart, docker, pubdev, webapp
- Language: CSS
- Homepage: https://pub.dev/packages/webapp
- Size: 1.4 MB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
### Run
```shel
docker compose up --build
```## Examples
Please refer to the documentation and the GitHub page for a comprehensive review of the examples. You can also view the example as a [Demo](https://webapp.uproid.com).### [View Examples](https://github.com/uproid/webapp/tree/master/example) | [Live Demo](https://webapp.uproid.com) | [Documentations](https://github.com/uproid/webapp/tree/master/doc)
```dart
import 'package:webapp/wa_console.dart';
import 'package:webapp/wa_server.dart';
import 'package:webapp/wa_tools.dart';
import 'lib/route/socket_route.dart';
import 'lib/route/web_route.dart';WaConfigs configs = WaConfigs(
widgetsPath: pathTo(env['WIDGETS_PATH'] ?? "./example/widgets"),
widgetsType: env['WIDGETS_TYPE'] ?? 'j2.html',
languagePath: pathTo(env['LANGUAGE_PATH'] ?? "./example/languages"),
publicDir: pathTo(env['PUBLIC_DIR'] ?? './example/public'),
dbConfig: WaDBConfig(enable: false),
port: 8085,
);WaServer server = WaServer(configs: configs);
final socketManager = SocketManager(
server,
event: SocketEvent(
onConnect: (socket) {
server.socketManager?.sendToAll(
"New user connected! count: ${server.socketManager?.countClients}",
path: "output",
);
socket.send(
{'message': 'Soccuess connect to socket!'},
path: 'connected',
);
},
onMessage: (socket, data) {},
onDisconnect: (socket) {
var count = server.socketManager?.countClients ?? 0;
server.socketManager?.sendToAll(
"User disconnected! count: ${count - 1}",
path: "output",
);
},
),
routes: getSocketRoute(),
);void main() async {
server.addRouting(getWebRoute);
server.start().then((value) {
Console.p("Example app started: http://localhost:${value.port}");
});
}```