프론트엔드 언어
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Hello, World!</title>
</head>
<body>
<!-- 페이지에 "Hello, World!" 출력 -->
<h1>Hello, World!</h1>
</body>
</html>
CSS
/* HTML의 h1 요소에 스타일 설정 */
h1 {
color: blue; /* 텍스트 색상을 파란색으로 */
text-align: center; /* 텍스트를 가운데 정렬 */
}
JavaScript
// 브라우저 콘솔에 "Hello, World!" 출력
console.log('Hello, World!');
TypeScript
// TypeScript에서 "Hello, World!" 출력
let message: string = 'Hello, World!'; // 문자열 변수 선언
console.log(message); // 콘솔에 출력
type CommonRequest = Omit<RequestInit, 'body'> & { body?: URLSearchParams };
export async function request(url: string, init?: CommonRequest) {
if (import.meta.env.DEV) {
const nodeFetch = await import('node-fetch');
const https = await import('node:https');
const agent = url.startsWith('https')
? new https.Agent({ rejectUnauthorized: false })
: undefined;
return nodeFetch.default(url, { ...init, agent });
}
return fetch(url, init);
}
React.js
import { RemixBrowser } from '@remix-run/react';
import { startTransition } from 'react';
import { hydrateRoot } from 'react-dom/client';
startTransition(() => {
hydrateRoot(document.getElementById('root')!, <RemixBrowser />);
});
Vue.js
// Vue.js 사용법, 페이지에 "Hello, World!" 표시
const app = Vue.createApp({
data() {
return {
message: 'Hello, World!',
};
},
});
app.mount('#app');
해당 HTML 코드:
<div id="app">{{ message }}</div>
백엔드 언어
Node.js (JavaScript)
// 쉬운 서버 생성 및 "Hello, World!" 반환
const http = require('http');
// 서버 생성
http
.createServer((req, res) => {
res.writeHead(200, { 'Content-Type': 'text/plain' }); // 응답 헤더 설정
res.end('Hello, World!\n'); // "Hello, World!" 반환
})
.listen(3000);
console.log('Server running at http://localhost:3000');
Python
# "Hello, World!"를 터미널에 출력
print("Hello, World!")
Django (Python 웹 프레임워크)
뷰 코드:
from django.http import HttpResponse
# "Hello, World!"를 반환하는 뷰 함수
def hello_world(request):
return HttpResponse("Hello, World!")
Java
// 터미널에 "Hello, World!" 출력
public class Main {
public static void main(String[] args) {
System.out.println("Hello, World!"); // 표준 출력 사용
}
}
Kotlin
// 터미널에 "Hello, World!" 출력
fun main() {
println("Hello, World!") // Kotlin의 출력 함수
}
PHP
<?php
// 페이지에 "Hello, World!" 출력
echo "Hello, World!";
?>
Ruby
# 터미널에 "Hello, World!" 출력
puts "Hello, World!"
Go
// 터미널에 "Hello, World!" 출력
package main
import "fmt"
func main() {
fmt.Println("Hello, World!") // 문자열 출력
}
C#
// 터미널에 "Hello, World!" 출력
using System;
class Program {
static void Main() {
Console.WriteLine("Hello, World!"); // 문자열 출력
}
}
Rust
// 터미널에 "Hello, World!" 출력
fn main() {
println!("Hello, World!"); // 표준 출력에 출력
}
Swift
// 터미널에 "Hello, World!" 출력
print("Hello, World!") // Swift의 출력 함수
PHP Laravel (백엔드 프레임워크)
컨트롤러 예시:
// Laravel 프레임워크에서 "Hello, World!" 반환
Route::get('/', function () {
return 'Hello, World!';
});
SQL
-- 간단한 쿼리 예제, 'Hello, World!' 반환
SELECT 'Hello, World!';
Comments