我们可以将Redis添加到DART的快速入门Web应用程序中吗?

cuxqih21  于 2022-09-21  发布在  Redis
关注(0)|答案(1)|浏览(257)

我想写我自己的程序。为此,我选择了DART语言,并使用了tutorial: get started with a web app

我的程序需要对来自Redis的数据进行反序列化。就目前而言,它在这里受阻。
一个外部的Python程序用JSON序列化数据,并使用lpush在Redis上发送数据。

我在Web服务器上有一个编译错误,我无法摆脱它。

  1. //library db.redis;
  2. import 'dart:html';
  3. import 'dart:convert';
  4. import 'dart:core';
  5. import 'package:redis/redis.dart';
  6. //import 'package:redis_client/redis_client.dart';
  7. //import 'package:redis';
  8. Iterable<String> thingsTodo() sync* {
  9. yield "walk the dog";
  10. yield "wash the dog";
  11. }
  12. LIElement newLI(String itemText) => LIElement()..text = itemText;
  13. void main() {
  14. querySelector('#output')?.children.addAll(thingsTodo().map(newLI));
  15. const jsonString = '{"text": "Your app is running", "value": 1, "status": false, "extra": null}';
  16. final data = jsonDecode(jsonString);
  17. final conn = RedisConnection();
  18. //final client = await conn.connect('localhost');
  19. //conn.connect('localhost', 6379).then((Command command){
  20. // command.send_object(["SET","key","0"]).then((var response)
  21. // print(response);
  22. // )
  23. //}
  24. //final client = await RedisClient.connect('localhost');
  25. //await client.set('name', 'Gabriel');
  26. //var res = await client.get('name');
  27. //print(res);
  28. //await client.close();
  29. querySelector('#end').text = data['text'];
  30. }

当我尝试添加Redis时,我总是在控制台上收到带有webdev serve命令的错误消息。

最后一条:
[警告]BUILD_Web_COMPILES:web/main.dart上的入口点:跳过
使用DDC编译QuickStart|web/main.dart,因为它的某些可传递库具有此平台不支持的SDK依赖项:

redis|lib/redis.dart

Https://github.com/dart-lang/build/blob/master/docs/faq.md#how-can-i-resolve-skipped-compiling-warnings

pbpqsu0x

pbpqsu0x1#

您正在为Web编译DART(将其转换为JavaScript和HTML)。并且不支持redis包。

如果你正在尝试建立真正的网页,你可能运气不佳。

但如果你想要一个控制台应用程序(我想这是正确的),那就试试this example。这将在您的系统上运行脚本(program),而不是构建网页。

相关问题