python - href 不能将我转移到 html 页面?
问题描述
我在这里尝试创建 cv 网站,除了图像之外,一切正常,当我运行项目并与我联系时,它应该将我转移到 contact.html 页面,但它不起作用,请我遵循一些课程,并确保每件事都一样但我不知道问题出在哪里
感谢你
公民.py:
from flask import Flask, render_template
from flask.helpers import url_for
project=Flask(__name__)
@project.route("/")
def enterance():
return render_template("enterance.html")
project.run()
模板/Hajar.png
模板/enterance.html:
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<title>HajarBaabbad</title>
</head>
<body>
<table cellspacing="20">
<td>
<img src="Hajar.png" alt="Hajar Logo">
</td>
<td>
<h2>My Hobbies</h2>
<ul>
<li>reading book</li>
<li>swemming</li>
</ul>
<hr>
</td>
</table>
<h1>Hajar Abdullah Ba'abbad</h1>
<p>python developer</p>
<p>personal linkedin page: <a href="https://www.linkedin.com/in/hajar-baabbad-7714951a0/">My linkedin pg</a> </p>
<hr>
<h2>My Experience</h2>
<ol>
<li>Computer Teacher</li>
<p><strong>August 2018 - August 2019
</strong>
<p><em>Success International School Riyadh</em></p>
May 2014 - August 2019
Set in classes of fellow teaching professionals to learn innovative methods for
dispensing information to students.
•
Established positive rapport with all students and parents through home
calls, emails and Parent Teacher Club.
•
• Assisted children per station during small-group learning periods.
Prepared instruction materials including copying, construction of bulletin
boards, grading work and setting up work areas.
•
• Administered and graded tests and assignments to evaluate students' progress.
• Planned and supervised class projects, field trips and visits by guest speakers.
Leveraged diverse learning strategies to prepare students for higher-level
education requirements.
</p>
<li>
Executive Secretary
<p><strong>Success International School, Riyadh</strong></p>
<p>May 2014 - August 2019</p>
<p>
Answered and managed incoming and outgoing calls while recording
accurate messages for distribution to office staff.
Greeted incoming visitors and customers professionally and provided
friendly, knowledgeable assistance.
Managed paper and electronic filing systems by routing various documents,
taking messages and managing incoming and outgoing mail.
Composed internal memos and external correspondence for senior
management and reviewed all documentation to eliminate errors.
Identified and recommended changes to existing processes to improve
accuracy, efficiency and responsiveness of customer service department.
</p>
</li>
</ol>
<hr>
<h2>Education</h2>
<ol>
<li>Bachelor of Administrative Science</li>
<li>Diploma of Programming & Databases</li>
</ol>
<hr>
<h2>Certificates:</h2>
<ul>
<li> Certified Entry-Level Python Programmer( PCEP) OpenEDG Python institute- 2021</li>
<li> Fundamentalsof Python programming - 2020
</li>
<li> Projects in Django: Learn Djangobuilding project - 2020
</li>
<li> Certificate in IT SkillsCIT - 2020
</li>
<li>
Complete motivation power - 2012
</li>
<li>
Goals Creation - 2016
</li>
</ul>
<hr width="10">
<hr>
<h2>My Skills</h2>
<table cell>
<tr>
<th>Python</th>
<td>❤</td>
<th>Java</th>
<td></td>
</tr>
<tr>
<th>reading</th>
<td></td>
<th>writing</th>
<td>✔</td>
</tr>
</table>
<a href="contact.html" >contact me</a>
</body>
</html>
模板/contact.html:
<!DOCTYPE html>
<head>
<meta charset="ut-8">
<title>Contact Info</title>
</head>
<body>
<h3>My Contact information :</h3>
<p>KSU, Riyadh (Olaya)</p>
<p>tel:05847213</p>
<p>po:12345</p>
<p>my email:hajar@gmail.com</p>
<form action="mailto:Almuttahida@gmail.com" method="post" enctype="text/plain">
<label><strong>your name:</label></strong><br>
<input type="text" name="your name" value=""><br>
<label><strong>your email</strong></label><br>
<input type="email" name="your email" value=""><br>
<label><strong>your message:</strong></label><br>
<textarea name="message" rows="10" cols="10"></textarea><br>
<input type="submit" name="">
</form>
</body>
</html>
我的项目包含 scrp 文件夹,因为 venv 我激活了它的脚本、模板包和 civi.py,下面我将通过 scrp 树和模板树
模板树:
templates
┣ contact.html
┣ enterance.html
┗ Hajar.png
scrp 树:(我删除了大部分代码,因为它比这里可用的时间长)
scp
┣ Include
┣ Lib
┃ ┗ site-packages
┃ ┃ ┣ click
┃ ┃ ┃ ┣ __pycache__
┃ ┃ ┃ ┃ ┣ core.cpython-38.pyc
┃ ┃ ┃ ┃ ┣ decorators.cpython-38.pyc
┃ ┃ ┃ ┃ ┣ exceptions.cpython-38.pyc
┃ ┃ ┃ ┃ ┣ formatting.cpython-38.pyc
┃ ┃ ┃ ┃ ┣ globals.cpython-38.pyc
┃ ┃ ┃ ┃ ┣ parser.cpython-38.pyc
┃ ┃ ┃ ┃ ┣ shell_completion.cpython-38.pyc
┃ ┃ ┃ ┃ ┣ termui.cpython-38.pyc
┃ ┃ ┃ ┃ ┣ testing.cpython-38.pyc
┃ ┃ ┃ ┃ ┣ types.cpython-38.pyc
┃ ┃ ┃ ┃ ┣ utils.cpython-38.pyc
┃ ┃ ┃ ┃ ┣ _compat.cpython-38.pyc
┃ ┃ ┃ ┃ ┣ _termui_impl.cpython-38.pyc
┃ ┃ ┃ ┃ ┣ _textwrap.cpython-38.pyc
┃ ┃ ┃ ┃ ┣ _unicodefun.cpython-38.pyc
┃ ┃ ┃ ┃ ┣ _winconsole.cpython-38.pyc
┃ ┃ ┃ ┃ ┗ __init__.cpython-38.pyc
┃ ┃ ┃ ┣ core.py
┃ ┃ ┃ ┣ decorators.py
┃ ┃ ┃ ┣ exceptions.py
┃ ┃ ┃ ┣ formatting.py
┃ ┃ ┃ ┣ globals.py
┃ ┃ ┃ ┣ parser.py
┃ ┃ ┃ ┣ py.typed
┃ ┃ ┃ ┣ shell_completion.py
┃ ┃ ┃ ┣ termui.py
┃ ┃ ┃ ┣ testing.py
┃ ┃ ┃ ┣ types.py
┃ ┃ ┃ ┣ utils.py
┃ ┃ ┃ ┣ _compat.py
┃ ┃ ┃ ┣ _termui_impl.py
┃ ┃ ┃ ┣ _textwrap.py
┃ ┃ ┃ ┣ _unicodefun.py
┃ ┃ ┃ ┣ _winconsole.py
┃ ┃ ┃ ┗ __init__.py
解决方案
欢迎来到 SO,
我观察到您代码中的相对 URL 不正确。
以下是一些使用相对路径的示例:
引用相对路径,您可以使用以下语法引用当前工作目录:./image.png
要移动到子文件夹,只需键入:./subfolder/image.png
如果您在子文件夹中工作并且想要引用父文件夹,您可以编写:../
.
../../
向后移动两个目录(等等......)
在您的具体情况下,只需编辑如下:
<img src="./Hajar.png" alt="Hajar Logo">
<a href="./contact.html" >contact me</a>
移动到联系页面的另一种方法是创建一个新的路由函数,如下所示:
@project.route("/contact")
def contact():
return redirect(url_for('contact'))
然后在锚标签中调用它:
<a href="/contact" >contact me</a>
它应该可以工作,如果不是,我恳请您评论或编辑问题并清楚地显示您项目的文件夹树。
推荐阅读
- netty - 确定客户端与 netty 服务器协商的 TLS 版本
- javascript - React 应用程序不使用 Ajax 将文件发送到 php 服务器
- firebase - flutter_cache_manager 与所有其他依赖项不兼容
- go - 在 terraform 提供程序中处理“变更集”
- html - 位于 Google 表格中的单元格下拉列表
- c++ - 如何将 const unordered_map 中的值分配给另一个 const 变量 - C++
- npm - 在“npm update -g”期间,如何跟踪引发警告的依赖项?
- javascript - JSON 中的意外令牌 D 位于位置 1 错误
- c++ - QString 类中的 toLocal8bit 方法安全吗?
- javascript - 可变阴影导致功能失败