node.js 如何返回json

用这句代码

 


具体实现为:

执行 node  app.js

当访问 http://IP:3000/countrys ,  会返回正确的json字符串

 


 

参考文章

https://stackoverflow.com/questions/19696240/proper-way-to-return-json-using-node-or-express


https://www.youtube.com/watch?v=EwHMSxSWIvQ   

这个教程非常好+


图片都存在 imgbb,google 账号登陆

 

flutter 与服务器交互部分

  • register

例子: https://stackoverflow.com/questions/51848973/flutter-using-http-request-to-register

更好的例子:  https://androidkt.com/http-post-request-in-flutter/

 

  • 从服务器查 所有国家, 应该返回什么

国家图片的url ,  以及这个国家的所有 situations 和相应的图片 ,应该是一个json字符串 ,格式大致为 :

 

  • 登陆后, 个人 profile应该返回什么

 

  • 如果处于登陆状态下, 访问了那个国家, 如果停留时间超过N秒, 标记为感兴趣的国家

 

  • 也可以暂时用 json-generator 代替服务器返回 json

 

 

flutter tips

    • in yaml file add this line , 可以在 save 之后立即看到界面的更改效果

dependencies:
flutter:
sdk: flutter
uses-material-design: true

  • 如何设置 background image

https://stackoverflow.com/questions/44179889/flutter-sdk-set-background-image

  • image 从哪里找

https://flutter.dev/docs/development/ui/assets-and-images

这个文章讲   Adding assets and images – Flutter

assets 可以理解为 resources

还可以参考这个 https://medium.com/@suragch/how-to-include-images-in-your-flutter-app-863889fc0b29

最终方法是 :   在项目跟目录下新建 :  assets\images , 图片放进去

然后在  yaml 改写 :

最后

‘assets/images/lake.jpg’  这样引用

 

  • 如何设置背景图片

https://stackoverflow.com/questions/44179889/flutter-sdk-set-background-image

 

可用的方法是 :

 

child 可以是 container , 把上面的代码改为 :

 

会显示出一个logo

但是, 如何在背景图上面加上 button ?  如果把上面一段代码改为

会发现 text 被显示


最终能在背景图片上显示button的代码为:

 

 

 

以下的一段简单代码 :

看起来很正确, 但是会引发这个错误 ,经google, 原因是 :

 

 

这个错误的解决方法 :

https://stackoverflow.com/questions/53923928/no-directionality-widget-found-inkwell-widgets-require-a-directionality-widget

 

  • 如何给 container 设置边框以确定其实际位置

 

来自: https://stackoverflow.com/questions/47423297/how-to-add-a-border-to-a-widget-in-flutter

 

  • 如何给 raisebutton 设置成圆角button :  加 shape 属性

 

  • 有时候不能改raisebutton的背景色,是因为

From RaisedButton documentation:

If the [onPressed] callback is null, then the button will be disabled and by default will resemble a flat button in the [disabledColor]. If you are trying to change the button’s [color] and it is not having any effect, check that you are passing a non-null [onPressed] handler.

  • 如何在不同页面之间 route

https://flutter.dev/docs/cookbook/navigation/named-routes

但是, 如果用这个方法, 文档中提到: When using initialRoutedon’t define a home property.

意思说 ,meterialapp 不能有home 属性, 所以不使用这个文档的方法, 经google, 实际用的是这个: https://www.youtube.com/watch?v=DlArCl8jvlo

 

关键代码是:  导航的raisebutton 这样写:

 

 

  • 如果 Scaffold 只占屏幕的一半:

 

  • 如何实现多个按钮组

来源 : https://stackoverflow.com/questions/57509675/horizontal-button-group-in-flutter

 

关键字 :  flutter wrap RaisedButton

 

  • appbar 其他全透明,只显示一个后退箭头, 让背景图片全屏,

 

关键字 stack widget

来源:  https://stackoverflow.com/questions/51508257/how-to-change-the-appbar-back-button-color

 

https://stackoverflow.com/questions/53080186/make-appbar-transparent-and-show-background-image-which-is-set-to-whole-screen

 

  • flutter 实现类似这样的 image listview

 

例子程序来源自: https://www.codeproject.com/Articles/1252727/Flutter-Getting-Started-Tutorial-4-ListView

 

更好的是这个: https://flutterbyexample.com/list-view-and-builder-methods/

 

最简单的listview : https://pusher.com/tutorials/flutter-listviews

 

 

  • 一个完整的flutter login 例子

https://pub.dev/packages/flutter_login#-readme-tab-

 

  • 个人开发的flutter 组件库

https://github.com/samarthagarwal/FlutterScreens

如何从头写一个flutter app

  •  用命令行新建项目

  • 把 lib/main.dart.   的所有代码删除

用这段 替换

 

 

 

  • 参考文章

https://flutter.dev/docs/get-started/codelab

简单的app


https://flutter.dev/docs/development/ui/layout

讲解界面layout, 以及各种布局例子

 

How to install flutter dev env

  • For windows

goto this site to download SDK :

https://flutter.dev/docs/get-started/install/windows

download this one :  flutter_windows_v1.12.13+hotfix.5-stable.zip

in disk C ,  create folder :src

unzip and place it under c:/src


接下来去   c:/src/flutter/bin , 执行 flutter doctor -v , 目的是检查所有 license 和 dependency 是否齐全 , 如果有缺少, 按提示安装


安装 android studio


为  android studio 安装  flutter plugin  , 方法:

file—>settings—->plugin  ,  选择 flutter 安装


开启手机的usb调试选项

1.打开华为手机的开发者选项:
打开“设置”界面——>点击“系统”——>点击“关于手机”——>连续点击“版本号”,点击5次左右,直到手机提示已开启开发者模式

2.打开开发人员选项
1、打开“开发人员选项”

2、打开”USB调试“选项

3、打开“仅充电模式下允许ADB调试”选项。

如果不打开“仅充电模式下允许ADB调试”选项 导致AndroidStudio 连接不上华为手机,而且关闭开发人员选项页面再进来,会发现usb调试打开后自动关闭,打开“仅充电模式下允许ADB调试”选项就可以了!!
————————————————
版权声明:本文为CSDN博主「shan_zwq」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/shanshan_1117/article/details/89188812


实验后发现, 用真实手机测试不可用, 所以在 Android studio 安装一个模拟器,方法是:  tools—> AVD manager —->create

创建后要保证 在console 执行  flutter emulators 能看到这个模拟器

 


然后在 android studio 新建一个 flutter project ,  按下图选择执行环境

点击run即可


 

参考文章 :

https://flutter.dev/docs/get-started/install/windows

https://developer.android.com/studio/run/win-usb

https://enappd.com/blog/setup-flutter-in-windows-and-mac/36/

https://flutter.dev/docs/development/tools/android-studio

https://enappd.com/blog/setup-flutter-in-windows-and-mac/36/

https://stackoverflow.com/questions/49045393/flutter-run-no-connected-devices

 

 

 

 

 

How to gitlab cl cd

To use GitLab CI/CD, all you need is an application codebase hosted in a Git repository, and for your build, test, and deployment scripts to be specified in a file called .gitlab-ci.yml, located in the root path of your repository.

需要写 gitlab-ci.yml 文件 来描述如何自动化 ci , cd

 

Once you’ve added your .gitlab-ci.yml configuration file to your repository, GitLab will detect it and run your scripts with the tool called GitLab Runner, which works similarly to your terminal.

写完以后用 gitlab runner 来执行 yml 文件


 

 

 

 

 

prepare for malaysia trip

  • what opentok – api can do

: to generate OpenTok sessions (session 相当于房间 ),

session never expired , also can not be explicit destroy .  user connect to session use token , token can be expired.


once a session is created ,  should define  how clients in the session will send audio-video streams,  there are two types :

a) Relayed   : mean p2p ,  but if in case can not connect cause firewall or other reason , will use opentok TURN server to relay .

b)Routed , 全部由 opentok 中转

The OpenTok Media Router supports the OpenTok archiving feature,  是否想录像必须是这个模式

In clients using the OpenTok iOS and Android SDKs, relayed sessions support only two clients connected to the session. The OpenTok Media Router supports additional clients for multiparty sessions on mobile devices.

手机版 relay 模式只支持2个client直连

如果正确选择这2种模式?

Choosing Relayed vs. Routed session type

Use a relayed instead of a routed session, if you have only two participants (or maybe even three) and you are not using archiving. Using relayed sessions reduces the latency between participants, reduces the points of failure and you can get better quality video and audio in most cases.

Routed sessions are required if you want to archive your session. They are recommended if you have more than two or three participants in the session.

以上部分来自: https://tokbox.com/developer/guides/create-session/


  • How to create session on server side :  use node.js example

From  https://tokbox.com/developer/guides/create-session/node/

How to create token :  From https://tokbox.com/developer/guides/create-token/node/

之后, client 怎么知道 这个session id 和 token  ????

  • session 自带一些事件, 可以给这些事件设置回调, 比如统计room的在线人数

 

 

  • how many types of opentok-api

web;  android ; IOS; windows desktop;

  • show android and web example

 

 

 

 

 

 

  • what is web-rtc

mean :  web Real-Time Communications

 

How to write to a file in wow addon

来源网址:  https://us.battle.net/forums/en/wow/topic/20043655806

 

 

 

World of Warcraft
Forums
UI and Macro
Can an addon write to a log file?
The World of Warcraft community forums have moved!
These forums are in read-only mode. Please visit the new World of Warcraft community forums at https://us.forums.blizzard.com/en/wow

Can an addon write to a log file?
UI AND MACRO

Cold
<God Tier>
110 Human Mage
11030
3138 posts
Dec 12, 2015
Does wow allow addons to write data to a txt file for example?

Gello
<Underhill>
100 Gnome Priest
16605
4654 posts
Dec 12, 2015
Not directly. All file i/o is removed from addons.

However, an addon can tag a variable to be saved in the SavedVariables folder under the addon’s name. An addon can tag it to save in a global file or a per-character file.

And this variable can record stuff over time to create a log. (It’s how addons can keep track of stuff over time)

While this file can’t be forced into a format immediately recognizable to an outside program (unless it reads lua files), there may be an ODBC written up for doing this to convert to Access or maybe a csv for Excel or something.

Cold
<God Tier>
110 Human Mage
11030
3138 posts
Dec 12, 2015
Any chance you could link me to what you are talking about?

Every page I looked at has a common theme: Blizzard won’t allow io because of bots.

Never even heard a mention about what you just said.

Gello
<Underhill>
100 Gnome Priest
16605
4654 posts
Dec 12, 2015
I don’t know if this would qualify as a link for this intended purpose but:
http://wow.gamepedia.com/Saving_variables_between_game_sessions

It’s easier to explain by example. Create the two files named in bold in a folder called TargetLog under AddOns:

TargetLog.toc
## Interface: 60200
## Title: TargetLog
## Notes: Uses SavedVariables to log targets across multiple sessions
## SavedVariables: TargetLogData
TargetLog.lua

TargetLog.lua
TargetLogData = {} — initial value (will be overwritten when/if SavedVariables load)
local f = CreateFrame(“Frame”)
f:SetScript(“OnEvent”,function(self)
if UnitExists(“target”) then
local name = UnitName(“target”)
local level = UnitLevel(“target”)
local health = UnitHealthMax(“target”)
— adds date/time,name,level,health of target to TargetLogData
tinsert(TargetLogData,format(“%s,%s,%s,%s”,date(),name,level,health))
end
end)
f:RegisterEvent(“PLAYER_TARGET_CHANGED”)

The next time you log in, as you target stuff, it gathers a few bits of info about your target and adds it to a table (TargetLogData). This data will accumulate across sessions (the purpose of SavedVariables is to keep stuff between sessions).

Note the ## SavedVariables: TargetLogData in the .toc. This is where you tag a variable to save. Then the addon itself fills the variable (almost always a table) with stuff.

Now when you logout or reload (and ONLY when you logout or reload–addons can’t control when this stuff writes beyond forcing a /reload which a user is generally not going to want while they play), the contents of TargetLogData is saved to the file WTF\Account\%accountname%\SavedVariables\TargetLog.lua. This is a text file that looks like:

TargetLogData = {
“12/12/15 00:19:57,Lunarfall Infantry,100,195708”, — [1]
“12/12/15 00:19:59,Muradin Bronzebeard,100,29356200”, — [2]
“12/12/15 00:20:02,Deedree,90,17503”, — [3]
“12/12/15 00:20:05,Captain Towix,100,97854”, — [4]
“12/12/15 00:20:06,Officer Jeor,100,97854”, — [5]
“12/12/15 00:20:08,Alliance Sailor,100,1467810”, — [6]
“12/12/15 00:20:09,Lieutenant Thorn,94,63226”, — [7]
“12/12/15 00:20:11,Shield Captain Chien,100,97854”, — [8]
“12/12/15 00:20:13,Sentinel Dawnshadow,100,97854”, — [9]
“12/12/15 00:20:15,Ro,100,385260”, — [10]
“12/12/15 00:20:18,Lunarfall Infantry,100,195708”, — [11]
“12/12/15 00:20:19,Porter,2,50”, — [12]
“12/12/15 00:20:22,Seer Kazal,100,97854”, — [13]
“12/12/15 00:20:24,Aenir,90,14002”, — [14]
“12/12/15 00:20:25,Squiggy,90,35006”, — [15]
“12/12/15 00:20:27,Rooter the Ravenous,100,146781”, — [16]
“12/12/15 00:20:28,Lio the Lioness,98,65312”, — [17]
“12/12/15 00:20:29,Quintessence of Light,25,788”, — [18]
}

This is a lua table of the data saved. When you log in later, part of the addon loading process is to run any existing SavedVariables files, so the table you saved on last logout is created with previous data on next login.

That is the complete and total extent that addons are allowed to write files.

An addon cannot change the structure of this file. The table name and syntax (table = { stuff, stuff, stuff, etc }) is there so it can be run. An addon has no control over this. The game creates it for its own purpose and makes no accomidation for outside programs to read it. If they ever change the structure of this file it would probably be to encrypt it so outside programs can’t use it.

To use it as a log for an outside program would require massaging this text to remove the syntax stuff to get a CSV or whatever format you choose. And it’s important to remember that this stuff only writes on a logout/reload. They don’t want it writing in realtime to prevent outside programs from learning about what’s going on in the game.

Cold
<God Tier>
110 Human Mage
11030
3138 posts
Dec 12, 2015
Thanks!
Join the Conversation
Have something to say? Log in to join the conversation.
Thanks for visiting the Blizzard Forums (3.8.2) · Patch Notes
CAREERSABOUTSUPPORTCONTACT USPRESSAPI
©2019 BLIZZARD ENTERTAINMENT, INC. ALL RIGHTS RESERVED.
All trademarks referenced herein are the properties of their respective owners.
PRIVACYLEGALTERMSCOOKIES
en-US