Here are some code samples for web applications. Check out our JavaScript tutorials for more information on web development.
- React Application
- Create a simple React application using the following code snippet.
- React Logo
import React from 'react';
function App() {
return (
<div>
<h1>Hello, World!</h1>
</div>
);
}
export default App;
- Node.js Server
- Use Node.js to create a basic server with the following code.
- Node.js Logo
const http = require('http');
const server = http.createServer((req, res) => {
res.statusCode = 200;
res.setHeader('Content-Type', 'text/plain');
res.end('Hello, World!\n');
});
server.listen(3000, () => {
console.log('Server running on port 3000');
});
- Express Framework
- Learn how to use the Express framework to build web applications.
- Express Logo
const express = require('express');
const app = express();
app.get('/', (req, res) => {
res.send('Hello, World!');
});
app.listen(3000, () => {
console.log('Server running on port 3000');
});
For more web application code samples, visit our web development resources.