📅  最后修改于: 2023-12-03 15:18:11.169000             🧑  作者: Mango
"Oylar Ingilizcha" is a web application for learning English words with their pronunciation and definitions. The app provides an interactive interface for users to learn and practice English words from different categories.
const express = require('express');
const router = express.Router();
const Word = require('../models/word');
const { ensureAuthenticated } = require('../config/auth');
// Get all words from the database
router.get('/', ensureAuthenticated, async (req, res) => {
try {
const words = await Word.find({ user: req.user.id });
res.render('words/index', { words });
} catch (err) {
console.error(err);
}
});
// Add a new word to the database
router.post('/', ensureAuthenticated, async (req, res) => {
const { name, category, pronunciation, definition } = req.body;
const newWord = new Word({
name,
category,
pronunciation,
definition,
user: req.user.id
});
try {
await newWord.save();
res.redirect('/words');
} catch (err) {
console.error(err);
}
});
"Oylar Ingilizcha" is a great application for anyone who wants to learn English in a fun and interactive way. With its unique features and technologies, it provides a great learning experience for users of all levels.