1
私はダーツのプログラミングでは新しく、ダーツアプリを構築しています。サーバー側から始めたいと思います。私のウェブページのURLを入力するときに私のホームページを読み込むように。私のサーバー側でサーバからダーツアプリケーションを起動し、要素をロード
私はダーツのウェブページからチュートリアルから取っこのコードがあります。
var server;
try{
server = await HttpServer.bind(InternetAddress.LOOPBACK_IP_V6, 4040);
}catch(e){
print("Couldn't bind to port 4044: $e");
exit(-1);
}
await for(HttpRequest req in server){
var file = new File('index.html');
if(await file.exists()){
print("Serving index.html.");
req.response.headers.contentType = ContentType.HTML;
try{
await file.openRead().pipe(req.response);
}catch(e){
print("Couldn't read file: $e");
exit(-1);
}
}else{
print("Couldn't open index.html");
req.response..statusCode = HttpStatus.NOT_FOUND..close();
}
}
しかし、今私の問題は、私の要素は、CSSのように、ロードされていない、イメージなどのクライアント側についてですが。
You can see the appearance here
私はそれをロードするために私のサーバー側で何かを設定する必要があると思います。それは何ですか?
Dartブラウザアプリケーション( 'build/web/**')で 'pub build'を実行した結果、あなたのDartサーバーに出力されていると仮定しますか? –