首页 > 解决方案 > Nodejs使用静态路由

问题描述

在我的项目中,我有一个结构:

-- Development
---allure
----allure-report
-----index.html
---testcafe (running app folder)
----routes
-----test.js
----views
-----report.ejs
----package.json
----app.js

现在我想在我的浏览器中显示 index.html。为此,我使用:

app.use(express.static(path.join(__basedir , '../allure/allure-report/')))

这将创建“/development/allure/allure-report/”文件夹的路径。

现在我在 report.ejs 中使用模板:

<div class="iframe-container">
   <iframe src="index.html" allowfullscreen></iframe> 
</div>

但这会产生 404 错误。在我的想法中,这将呈现 index.html。这不起作用。这是错误的方式吗?

标签: javascriptnode.jsexpress

解决方案


推荐阅读