【发布时间】:2019-09-25 14:56:42
【问题描述】:
我创建了一个 Angular 网站,该网站向我使用 Flask 开发的后端发出请求。我的第一个任务是使用 Flask 为网站提供服务。
按照这个答案here,我设法在 Flask 服务器上为我的网站提供服务。
唯一的问题是我在网站上使用的图片没有出现。在使用 Flask 为网站提供服务之前,一切正常。但我不会收到这样的错误:
GET http://localhost:5000/assets/img/green_circle.png 404 (NOT FOUND)
这发生在我想展示的所有图片上。我的文件夹结构是这样的:
mainFolder
|-static
| |- contains all js and css files
| |- assets (CONTAINS IMAGES)
|-templates
| |-index.html
|-server.py
我的index.html 文件如下所示:
<!doctype html>
<html>
<head>
<base href="./">
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="CoreUI - Free Angular Admin Template">
<meta name="author" content="Łukasz Holeczek">
<meta name="keyword" content="Bootstrap,Admin,Template,Free,Angular,Dashboard,Typescript">
<link rel="icon" href="assets/favicon.ico">
<title>WINGS Smart Parking System</title>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-118965717-3"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
// Shared ID
gtag('config', 'UA-118965717-3');
// Angular ID
gtag('config', 'UA-118965717-4');
</script>
</head>
<body class="app">
<!-- App Loading... -->
<script src="/static/runtime.js"></script>
<script src="/static/polyfills-es5.js" nomodule></script>
<script src="/static/polyfills.js"></script>
<script src="/static/styles.js"></script>
<script src="/static/scripts.js"></script>
<script src="/static/vendor.js"></script>
<script src="/static/main.js"></script>
<script src="/static/views-dashboard-dashboard-module.js"></script>
<script src="/static/views-buttons-buttons-module.js"></script>
<script src="/static/views-chartjs-chartjs-module.js "></script>
</body>
</html>
你有什么想法吗?提前致谢!
【问题讨论】: