AIGPAIGP

Bun HTTP Server: Zero Config, 10x Faster

P

Prompt

Build an ultra-fast HTTP server using Bun runtime. Show a complete example with routing, JSON response, and file serving. Use no frameworks, just Bun's built-in APIs.

CODE PREVIEW

エディタを読み込み中…

AIとの対話に追加する一言

プロンプトと一緒にコピーして、AIがより正確に意図を汲み取れるようにします

このコードをそのまま使いたいので、CDNリンクも含めた完全なHTMLファイルとして出力してください。

初心者なので、各行にコメントを追加して、何をしているか説明してください。

このコードをWordPressのテーマに組み込む方法も教えてください。

動作確認済みのコードをお願いします。エラーが出る場合の対処法も含めて。

Bun は高速なオールインワンJavaScriptランタイムです。BunでHTTPサーバーを構築するのは信じられないほど簡単で、フレームワークも設定も不要です。組み込みの serve 関数を使うだけ。

以下はルーティング、JSON API、HTMLファイル配信を含む完全な例です。bun run server.js で実行できます。

  • / ルートは動的なHTMLページを配信
  • /api/hello はタイムスタンプ付きのJSONを返す
  • /api/data はサンプルデータを返す
  • /public/ は静的ファイルを配信

BunのHTTPサーバーは最小限のメモリで毎秒数千リクエストを処理します。マイクロサービス、API、プロトタイピングに最適です。

Prompt Overview

Bun is a fast all-in-one JavaScript runtime. Building an HTTP server with Bun is incredibly simple — no frameworks, no configuration. Just use the built-in serve function.

Here's a complete example with routing, JSON API, and HTML file serving. Run it with bun run server.js.

  • Route / serves a dynamic HTML page
  • /api/hello returns JSON with a timestamp
  • /api/data returns sample data
  • /public/ serves static files

Bun's HTTP server handles thousands of requests per second with minimal memory. Perfect for microservices, APIs, and prototyping.

Was this prompt helpful?

Comments

Comments appear after moderation

この記事が役に立ったら投げ銭で応援

Apple Pay / Google Pay / カード (Visa/Mastercard/JCB/Amex) / Link / Alipay / WeChat Pay 対応 · Stripeで安全に決済

開発者が選ぶ最強ツール集

運営者が毎日使っているツール・ガジェット 6選

見る
Homeヘルプ