使用Express & MongoDB作为POST请求时,我将得到404。我多次尝试重做我的路线,但是登录页面有问题。我希望将这些信息发布到我的服务器上,并呈现一个简单的“欢迎消息”。请给我建议。
路由文件夹:
var express = require('express');
var router = express.Router();
let mongoose = require('mongoose');
var User = require('../models/users')
//Get registration page fr
express website
npm WARN deprecated jade@1.11.0: Jade has been renamed to pug, please install the latest version of pug instead of jade
npm WARN deprecated transformers@2.1.0: Deprecated, use jstransformer
(我只是在学习一个教程。)安装jstransformer和pug还不够吗?我应该编辑express的代码吗?我可以将这样的东西用于生产吗?
我不明白弃用是如何工作的,我能做些什么。
我正在尝试通过setInterval()重新呈现我的pug模板。
我正在尝试让页面显示来自MySQL服务器的实时数据。我可以将数据放到页面上,但是我不知道如何更新显示的数据而不刷新整个页面。
我尝试实现AJAX,并试图通过socket.io实现这一点,但两次尝试都未能将数据发送到pug模板。
Server.js
var express = require('express');
var app = express();
var http = require('http');
var server = http.createServer(app);
var pug
我是pug新手,现在我正在尝试呈现一个html视图,其中包含一个表,该表的条目是从app.js解析的
这是我的index.pug
doctype html
html(lang='en')
head
title Pug
body
table
- var columns = ['apple', 'pine', 'peach'];
tr
each column in columns
我正在尝试在PugJS中创建一个可点击的按钮(执行节点JS中的js)。 视图/index.pug doctype html
html
head
title #{title}
link(rel='stylesheet', href='/css/style.css')
meta(name="viewport" content="width=device-width, initial-scale=1")
body
main
block header
header.he
我正在尝试使用express在html中显示我的JSON文件的内容
const data = require("./data.json");
const express = require("express");
const morgan = require("morgan");
var pug = require("pug");
//import mongoose from "mongoose";
//import port from "./config/config";
//const ruta
在我的项目中设置视图引擎时,我使用了这个代码片段,应用程序运行得很好。
// configurations for the view engine
app.set('views', './views');
app.set('view engine', 'pug');
但是,我已经看到教程使用了一种不同的方法,它们将"__dirName“附加到其中。我不太熟悉express以及它是如何工作的,所以我想知道下面代码片段的功能。请给我解释一下,这样我才能理解它的适用性。
// configurations for the vie
我正在尝试在我的节点应用程序中使用pug,因为jade现在被销毁了,并且我的app.js看起来像这样:
var express = require('express');
var path = require('path');
var bodyParser = require('body-parser');
var nodemailer = require('nodemailer');
var app = express();
// tells which folder the template files will be i
我正在用快车试试看帕格
views/layout.pug
doctype html
html
head
title= title
link(rel="shortcut icon", href="favicon.ico", type="image/x-icon")
link(rel='stylesheet', href='/assets/application.css')
link(rel='stylesheet', href="assets/libs/
嗨,伙计们,我最近刚开始玩帕格(玉),我不能加载我的布局
这里是我的layout.pug
html(lang='en')
head
title hi
link(rel='stylesheet', type='text/css', href='../public/css/W3.css')
link(rel='stylesheet', href='https://fonts.googleapis.com/css?family=Allerta+Stencil')
body
编辑:根据正确的答案修改了标题,以帮助谷歌搜索
在下面的代码中,我在404.pug页面中的404.pug标记在404.pug页面中包含了header.pug之后,一直是h1标记的子标记。下面是我正在使用的代码:
Header.pug
doctype
html
head
meta(charset='utf-8')
title Express Guestbook
link(href="to/bootstrap.min.css", rel="stylesheet")
body.container
h1 E
Error: ENOENT: no such file or directory, open './views/transactions/html.pug'
在本地运行我的应用程序没有问题,一旦我推送到Heroku,我就会得到上面的错误。在本地,我使用nodemon为我的express服务器提供服务。我正在使用pug编译一些html来发送电子邮件。这就是导致问题的函数。
pug.compileFile('./views/transactions/html.pug')
使用node Express,使用React,从同一服务器提供静态/构建文件。
我怀
我有以下代码。有一个错误处理中间件,当我在浏览器上打开localhost:3000时,它会被调用,但响应永远不会是“系统暂时不可用”。相反,我得到了错误消息“我的自定义错误”以及完整的堆栈跟踪。 我的理解是错误的,一旦出现未处理的错误,express就会调用错误中间件?/ 代码 let express = require('express');
let app = express();
let pug = require('pug');
let session = require('express-session');
let passpo
我正在用Nodejs和Express在帕格制作一个网站。我创建了一个名为index.pug的文件。在这个文件中,我包括了我所有的帕格文件。
index.pug:
extends ../views/layout
block content
include home/page-content/Intro/Intro
include home/page-content/About/About
include home/page-content/Specialism/Specialism
include home/page-content/Contact/Contac
我正在尝试使用我在pug中创建的网页运行python脚本,在节点中表示。我更熟悉python而不是节点。使用下面的代码,如何运行python脚本?我包含python shell,但当我单击pug网页上的按钮时,不确定如何运行python脚本。
server.js
// require all dependencies
var express = require('express');
var app = express();
var PythonShell = require('python-shell');
// set up the template e
Error: /home/user/Desktop/app/backend/views/register.pug:2:1
1| doctype html
> 2| html
-------^
3| head
4| title = title
5| body
unexpected token "indent"
at makeError (/home/user/Desktop/app/backend/node_modules/pug-error/index.js:32:13)
at Parser