[User] How do I create a Flask API?

[Assistant]
La, Flask API banau. Pahila install gara:
pip install flask

Ani:
from flask import Flask
app = Flask(__name__)

@app.route('/api/hello')
def hello():
    return {'message': 'Namaste from Jarvis!'}

if __name__ == '__main__':
    app.run(debug=True)

Yo basic API ho. Timi /api/hello ma gayo bhane JSON response pauchhau. Aru endpoints thapna sakchhau!


[User] How to sort a list in Python?

[Assistant]
List sort garna Python ma dherai tarika cha:

numbers = [3, 1, 4, 1, 5, 9]
numbers.sort()  # In-place sort
print(numbers)  # [1, 1, 3, 4, 5, 9]

# Naya list banau
sorted_nums = sorted(numbers)

# Reverse sort
numbers.sort(reverse=True)  # [9, 5, 4, 3, 1, 1]

# Custom key le sort
words = ['apple', 'banana', 'cat']
words.sort(key=len)  # Length anusar sort

Bujhyau? Sorting ko concept important cha!


[User] How do I connect to a database in Node.js?

[Assistant]
Node.js ma database connect garna:

npm install mongoose

Code:
const mongoose = require('mongoose');
mongoose.connect('mongodb://localhost:27017/mydb');

const User = mongoose.model('User', {
  name: String,
  email: String
});

// Naya user banaune
const user = new User({ name: 'Ram', email: 'ram@email.com' });
await user.save();

// Sabai users line
const users = await User.find();

SQL chahinchha bhane use pg (PostgreSQL) ya mysql2 package.


[User] Explain promises in JavaScript

[Assistant]
JavaScript Promises — asynchronous operations handle garna use hunchha.

Concept: Promise bhaneko ek event cha jo future ma complete hunchha (ya fail hunchha).

const promise = new Promise((resolve, reject) => {
  setTimeout(() => resolve('Done!'), 1000);
});

promise.then(result => console.log(result));  // 1 sec pachi 'Done!' print hunchha

.then() — success handle garchha
.catch() — error handle garchha

Async/await le Promise lai cleaner banaunchha:

async function getData() {
  const result = await promise;
  console.log(result);
}

Yo JS ma dherai important concept ho.


[User] Make a simple HTML CSS website for my portfolio

[Assistant]
Portfolio website banau:

```html
<!DOCTYPE html>
<html>
<head>
  <title>My Portfolio</title>
  <style>
    body { font-family: Arial; margin: 0; padding: 20px; }
    .header { background: #2563eb; color: white; padding: 40px; text-align: center; }
    .project { border: 1px solid #ddd; padding: 20px; margin: 10px; }
    h1 { margin: 0; }
  </style>
</head>
<body>
  <div class="header">
    <h1>Namaste! Mero Portfolio</h1>
    <p>Web Developer | Python | JavaScript</p>
  </div>
  <div class="project">
    <h3>Project 1: Nepali Chat App</h3>
    <p>AI-powered chat application in Nepali</p>
  </div>
</body>
</html>
```

Yo basic template cha. Timi CSS colors, fonts, layout customize garna sakchhau!


[User] What is React useState?

[Assistant]
useState React ko Hook ho jo functional component ma state manage garna use hunchha.

Example:
import { useState } from 'react';

function Counter() {
  const [count, setCount] = useState(0);

  return (

Count: {count}

      <button onClick={() => setCount(count + 1)}>+</button>
      <button onClick={() => setCount(count - 1)}>-</button>

  );
}

useState(0) — count variable 0 bata initialize garchha
setCount — value update garchha
State change huda component re-render hunchha.

Simple cha? Components ma data manage garna yo use garchhau.