Node.js ile Express Framework Kullanarak API Geliştirme
Express.js, Node.js ile RESTful API’ler geliştirmek için en popüler framework’tür. Aşağıdaki örnek, basit bir “/api/kullanicilar” endpoint’i oluşturur ve JSON formatında yanıt döner.
const express = require("express");
const app = express();
const port = 4000;
app.get("/api/kullanicilar", (req, res) => {
res.json([
{ ad: "Bilal", sehir: "Manisa" },
{ ad: "Metin", sehir: "İzmir" },
]);
});
app.listen(port, () => {
console.log(`API http://localhost:${port} adresinde çalışıyor 🚀`);
});
Kod Açıklaması
Express.js, Node.js ile RESTful API’ler geliştirmek için en popüler framework’tür.
Aşağıdaki örnek, basit bir “/api/kullanicilar” endpoint’i oluşturur ve JSON formatında yanıt döner.
Nasıl Çalışır?
Bu kod örneği, Web Speech API kullanılarak sesli olarak açıklanmaktadır. Kod bloğunun üzerine mouse ile geldiğinizde otomatik olarak açıklama başlar.
Kullanım Alanları
Web Speech API
Bu kod örneği Web Speech API kullanılarak sesli olarak açıklanmaktadır.
İlgili Kodlar
const http = require("http");
const server = http.createServer((req, res) => {
res.writeHead(200, { "Content-Type": "text/html; charset=utf-8" });
res.end("<h2>Zebifytech Node.js Sunucusu Akt...
Node.js ile Basit HTTP Sunucusu Oluşturma
Kendi Konuşan Kodunuzu Oluşturun
Web Speech API ile kendi projelerinizde de konuşan kod örnekleri oluşturabilirsiniz.