added car configurator

This commit is contained in:
Jelaletdin12
2026-03-27 22:26:30 +05:00
parent 6ba07d7fef
commit c4ac669a09
26 changed files with 6009 additions and 93 deletions

41
server.js Normal file
View File

@@ -0,0 +1,41 @@
import express from "express";
import fs from "fs";
import path from "path";
const app = express();
const port = 3000;
// API endpointleri
app.post("/api/data", express.json(), (req, res) => {
fs.writeFile(path.join(process.cwd(), "public", "data.json"), JSON.stringify(req.body, null, 2), (err) => {
if (err) {
res.status(500).send(err.message);
} else {
res.status(200).json({ ok: true });
}
});
});
app.get("/api/data", (req, res) => {
fs.readFile(path.join(process.cwd(), "public", "data.json"), "utf-8", (err, data) => {
if (err) {
res.status(500).send(err.message);
} else {
res.setHeader("Cache-Control", "no-cache, no-store, must-revalidate");
res.setHeader("Pragma", "no-cache");
res.setHeader("Expires", "0");
res.setHeader("Content-Type", "application/json");
res.send(data);
}
});
});
// Statik dosyaları sun ve diğer tüm istekleri index.html'e yönlendir
app.use(express.static(path.join(process.cwd(), "dist")));
app.get(/^(?!\/api).*/, (req, res) => {
res.sendFile(path.join(process.cwd(), "dist", "index.html"));
});
app.listen(port, () => {
console.log(`Sunucu http://localhost:${port} adresinde çalışıyor`);
});