Skip to content

Commit

Permalink
get function for the API
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmetozydn committed Jul 7, 2023
1 parent fc13ee5 commit 7bfbc26
Show file tree
Hide file tree
Showing 10 changed files with 304 additions and 97 deletions.
23 changes: 23 additions & 0 deletions API.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
const express = require('express');
const app = express(); // framework to create server
const port = 8080;

// Serve the JSON file
app.get('/', (req, res) => {
// Path to the JSON file

// Set the appropriate Content-Type header
res.setHeader('Content-Type', 'application/json');

// Send the JSON file
res.sendFile(__dirname + '/data/products.json');
});



// Start the server
app.listen(port, () => {
console.log(`Server is running on port ${port}`);
});


19 changes: 19 additions & 0 deletions client.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
const net = require('net');

// Create a TCP socket and connect to the server
const client = new net.Socket();
client.connect(3000, 'localhost', () => {
console.log('Connected to server.');
});

// Handle data received from the server
client.on('data', data => {
console.log(`Received data from server: ${data}`);

// You can perform further actions with the received data here
});

// Handle server disconnection (optional)
client.on('close', () => {
console.log('Server connection closed.');
});
106 changes: 106 additions & 0 deletions data/products.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
[
{
"id": 0,
"name": "APPLE iPhone SE",
"color":"Black",
"ROM": 128,
"price": 990,
"modeName": "iPhone SE",
"modelNumber": "MHGT3HN/A",
"size": "11.94 cm (4.7 inch) Retina HD Display",
"camera": "12MP Rear Camera | 7MP Front Camera",
"Description": "Widescreen HD LCD Retina Multi-touch IPS Display (1400:1 Contrast Ratio (Typical), True Tone Display, Wide Color Display (P3), Haptic Touch, 625 nits Max Brightness (Typical), Fingerprint-resistant Oleophobic Coating, Display Zoom, Reachability)",
"productImage":"http://atlas-content-cdn.pixelsquid.com/stock-images/iphone-x-smartphone-xwVXQLD-600.jpg"
},
{
"id": 1,
"name": "APPLE iPhone XR",
"color":"White",
"ROM": 64,
"price": 790,
"modeName": "iPhone XR",
"modelNumber": "MH6N3HN/A",
"size": "15.49 cm (6.1 inch) Display",
"camera": "12MP Rear Camera | 7MP Front Camera",
"Description": "1400:1 Contrast Ratio (Typical), True Tone Display (Six-channel Light Sensor), Wide Colour Display (P3), 625 nits Maximum Brightness (Typical), Fingerprint-resistant Oleophobic Coating, Support for Display of Multiple Languages and Characters Simultaneously, Liquid Retina HD Display, Tap to Wake, Wide Colour Gamut",
"productImage":"https://c8.alamy.com/zooms/6/e98284ded5444c08949d7fd9f2bae166/2cd68c5.jpg"
},
{
"id": 2,
"name": "APPLE iPhone 11",
"color":"White",
"ROM": 64,
"price": 740,
"modeName": "iPhone 11",
"modelNumber": "MHDC3HN/A",
"size": "15.49 cm (6.1 inch) Liquid Retina HD",
"camera": "12MP + 12MP | 12MP Front Camera",
"Description": "1400:1 Contrast Ratio (Typical), True Tone Display, Wide Colour Display (P3), Haptic Touch, 625 nits Max Brightness (Typical), Fingerprint Resistant Oleophobic Coating, Support for Display of Multiple Languages and Characters Simultaneously",
"productImage":"https://png.pngtree.com/png-vector/20201230/ourlarge/pngtree-smart-phone-vector-3d-style-mobile-design-mockup-png-image_2679535.jpg"
},
{
"id": 3,
"name": "APPLE iPhone XR",
"color":"Yellow",
"ROM": 128,
"price": 999,
"modeName": "iPhone XR",
"modelNumber": "MHDC4HN/A",
"size": "15.49 cm (6.1 inch) Liquid Retina HD",
"camera": "12MP + 12MP | 12MP Front Camera",
"Description": "1400:1 Contrast Ratio (Typical), True Tone Display, Wide Colour Display (P3), Haptic Touch, 625 nits Max Brightness (Typical), Fingerprint Resistant Oleophobic Coating, Support for Display of Multiple Languages and Characters Simultaneously",
"productImage":"https://png.pngtree.com/png-vector/20201230/ourlarge/pngtree-vector-3d-style-smart-phone-mockup-design-png-image_2679529.jpg"
},
{
"id": 4,
"name": "APPLE iPhone 12 Mini",
"color":"Purple",
"ROM": 64,
"price": 720,
"modeName": "iPhone 12",
"modelNumber": "MGJE3HN/A",
"size": "13.72 cm (5.4 inch) Super Retina XDR Display",
"camera": "12MP + 12MP | 12MP Front Camera",
"Description": "Dive into a world of crystal-clear visuals with the Super Retina XDR Display of the iPhone 12 Mini. This beast of a smartphone packs the A14 Bionic chip to make for blazing-fast performance speeds. On top of that, its Dual-camera System, along with Night Mode, helps you click amazing pictures and selfies even when the lighting isn’t as good as you’d want it to be.",
"productImage":"https://cdn1.vectorstock.com/i/1000x1000/70/05/realistic-frameless-smartphone-mock-up-3d-vector-33107005.jpg"
},
{
"id": 5,
"name": "APPLE iPhone 11",
"color":"Red",
"ROM": 128,
"price": 990,
"modeName": "iPhone 11",
"modelNumber": "MHDC3HN/A",
"size": "15.49 cm (6.1 inch) Liquid Retina HD",
"camera": "12MP + 12MP | 12MP Front Camera",
"Description": "1400:1 Contrast Ratio (Typical), True Tone Display, Wide Colour Display (P3), Haptic Touch, 625 nits Max Brightness (Typical), Fingerprint Resistant Oleophobic Coating, Support for Display of Multiple Languages and Characters Simultaneously",
"productImage":"https://previews.123rf.com/images/barmaleeva/barmaleeva2003/barmaleeva200300004/141800762-white-realistic-smartphone-mockup-3d-mobile-phone-with-blank-white-screen-modern-vector-cell-phone-t.jpg"
},
{
"id": 6,
"name": "APPLE iPhone SE",
"color":"White",
"ROM": 64,
"price": 780,
"modeName": "iPhone SE",
"modelNumber": "MHGT3HN/A",
"size": "11.94 cm (4.7 inch) Retina HD Display",
"camera": "12MP Rear Camera | 7MP Front Camera",
"Description": "Widescreen HD LCD Retina Multi-touch IPS Display (1400:1 Contrast Ratio (Typical), True Tone Display, Wide Color Display (P3), Haptic Touch, 625 nits Max Brightness (Typical), Fingerprint-resistant Oleophobic Coating, Display Zoom, Reachability)",
"productImage":"http://atlas-content-cdn.pixelsquid.com/stock-images/iphone-x-smartphone-xwVXQLD-600.jpg"
},
{
"id": 7,
"name": "APPLE iPhone 12",
"color":"Blue",
"ROM": 64,
"price": 780,
"modeName": "iPhone 12",
"modelNumber": "MHGT3HN/A",
"size": "11.94 cm (4.7 inch) Retina HD Display",
"camera": "12MP Rear Camera | 7MP Front Camera",
"Description": "Widescreen HD LCD Retina Multi-touch IPS Display (1400:1 Contrast Ratio (Typical), True Tone Display, Wide Color Display (P3), Haptic Touch, 625 nits Max Brightness (Typical), Fingerprint-resistant Oleophobic Coating, Display Zoom, Reachability)",
"productImage":"https://cdn1.vectorstock.com/i/1000x1000/70/05/realistic-frameless-smartphone-mock-up-3d-vector-33107005.jpg"
}
]
12 changes: 12 additions & 0 deletions home.css
Original file line number Diff line number Diff line change
Expand Up @@ -182,4 +182,16 @@
display: inline-block;
}


.data{
width: 700px;
background-color: antiquewhite;
height: 400px;
color: #000;
}

::selection{
color: white;
background-color: #000;
}

32 changes: 18 additions & 14 deletions main.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
<title>WEB WORKSPACE </title>
<link rel="icon" type="image/x-icon" href="https://www.seiu1000.org/sites/main/files/main-images/camera_lense_0.jpeg">

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css"
integrity="sha384-Ky1qmkCEvXc5LP+NP2rr+qP6MH9xHAv1NpaaUmpgezBUw6lkVv+hVUKz45KH9DNh" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css">
<!-- <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"> -->
<link rel="stylesheet" href="home.css">
<link rel="stylesheet"
Expand All @@ -21,6 +20,8 @@


<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css" />


<style>

</style>
Expand Down Expand Up @@ -64,13 +65,13 @@
<div class=" card">
<h3 style="padding: 0; margin: 0px;">Clothes</h3>
<div class="card" style="width: 120px; height: 200px; background-color: beige;">
<p>this is inner card</p>
<p>the name of the product is dg</p>
</div>
<div class="card" style="width: 120px; height: 200px; background-color: beige;">
<p>this is inner card</p>
<p>this is inner card ad</p>
</div>
<div class="card" style="width: 120px; height: 200px; background-color: beige;">
<p>this is inner card</p>
<p>{{%MODELNO%}}</p>
</div>
<div class="card" style="width: 120px; height: 200px; background-color: beige;">
<p>this is inner card</p>
Expand All @@ -94,17 +95,12 @@ <h3 style="padding: 0; margin: 0px;">Clothes</h3>
<p>this is inner card</p>
</div>
<div class="card" style="width: 120px; height: 200px; background-color: beige;">
<p>this is inner card</p>
<p>sdsd</p>
</div>
</div>
<div class="data"></div>


<div class="scrollable-container">
<div class="scrollable-content">
<p>This is the scrollable content that will overflow horizontally.</p>
<p>You can add more content here to make it scrollable.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
</div>
</div>


</div>
Expand Down Expand Up @@ -141,8 +137,16 @@ <h3 style="padding: 0; margin: 0px;">Clothes</h3>
</nav>
</div>
</footer>
<script src="script.js"></script>
</button>

</p>

<p id = "data-output"></p>


<script >
src = "server.js"
</script>
</body>

</html>
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,9 @@
"express": "^4.18.2",
"json-server": "^0.17.3"
}



}


29 changes: 0 additions & 29 deletions products.json

This file was deleted.

Loading

0 comments on commit 7bfbc26

Please sign in to comment.