尝试呈现ejs时出现错误404。当res.send,router.get('/',(req,res,next)=> res.send('welcome'))时,该文件运行良好。并在页面上显示“欢迎”,但是当我使用res.render('welcome')时,出现错误404。我不知道自己在做什么错。我共享了我的app.js文件,路由器文件dashboard.js和我的ejs文件。所有帮助都将受到欢迎
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
void duplicateArray( const int *p_input_array, int num_input, int **pp_output_array, int *p_num_output )
{
int i = 0, j = 0;
// In the most extreme case, the output array must be 2 times larger than
// the input buffer, so we allocate double the size of the input buffer.
int *p_output_array = (int*)malloc( num_input * 2 * sizeof(int) );
assert( p_output_array != NULL );
while ( i < num_input )
{
int num_repetitions;
int k = p_input_array[i++];
//count the number of repetitions
for ( num_repetitions = 0; i < num_input && p_input_array[i] == k; num_repetitions++, i++ );
if ( num_repetitions == 0 )
{
p_output_array[j++] = k;
}
else
{
for ( int l = 0; l < num_repetitions + 1; l++ )
{
p_output_array[j++] = k;
p_output_array[j++] = k;
}
}
}
//shrink the array to the actually needed size
p_output_array = (int*)realloc( p_output_array, j * sizeof(int) );
assert( p_output_array != NULL );
*pp_output_array = p_output_array;
*p_num_output = j;
}
int main()
{
int arr[] = { 1, 8, 8, 70, 2, 2, 2, 5, 5, 2 };
int *p;
int num;
duplicateArray( arr, sizeof(arr)/sizeof(*arr), &p, &num );
for ( int i = 0; i < num; i++ ) {
printf( "%d\n", p[i] );
}
free( p );
}
welcome.ejs file
<div class="row mt-5">
<div class="col-md-6 m-auto">
<div class="card card-body text-center">
<h1><i class="fab fa-node-js fa-3x"></i></h1>
<p>Create an account or login</p>
<a href="/users/register" class="btn btn-primary btn-block mb-2"
>Register</a
>
<a href="/users/login" class="btn btn-secondary btn-block">Login</a>
</div>
</div>
</div>
dashboard.js
const express = require('express');
const router = express.Router();
router.get('/', (req, res, next) => res.render('welcome'));
module.exports = router;