0

i tried here to create c.v site , every thing work ok except image it not appear when i run th project and contact me it should transfer me to contact.html page but its not work , pleas i follow some course and am sure every thing same but i dont know where id th problem

thank u

civi.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()

templates/Hajar.png

templates/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>

templates/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>

my project contain scrp folder as venv i activated its scripts, and templates package and civi.py and below i'll past scrp tree& templates tree

templates tree:

templates
 ┣ contact.html
 ┣ enterance.html
 ┗ Hajar.png

scrp tree:(i deleted most of code cause its so long more than available here)

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
Sara
  • 1
  • 4

1 Answers1

0

Welcome to SO,

I observe that relative URLs in your code are incorrect.

Here are some examples of work with relative paths:

Referring to relative paths, you can refer to the current working directory with the following syntax: ./image.png

To move to a subfolder just type: ./subfolder/image.png

In case you are working in a subfolder and you want to refer to a parent folder you can write:../.

../../ moves two directories backward (and so on...)

In your specific case, just edit as below:

<img src="./Hajar.png" alt="Hajar Logo">

<a href="./contact.html" >contact me</a>

An alternative method to move to the contact page is to create a new route function as below:

@project.route("/contact")
def contact():
    return redirect(url_for('contact'))

and then call it in the anchor tag:

<a href="/contact" >contact me</a>

It should work, if not I kindly ask you to comment or edit the question and clearly show the folder tree of your project.

  • sorry can you tell me how ? i wrote it all , 1 .py file and the image with 2 html file inside template package .. :( – Sara Aug 01 '21 at 21:52
  • @Sara can you show me your current folder tree? here an example of a folder tree: [link](https://stackoverflow.com/a/47510993/13520994) – Marco Gatto Aug 01 '21 at 22:07
  • @Sara I changed my answer in relation to what you added to your question. Let me know if it works now – Marco Gatto Aug 02 '21 at 16:38
  • i am really stuck here it not work i changed th url as you said without any response same problem :| – Sara Aug 03 '21 at 01:24
  • actually when i run enterance.html inside V.S every thing works , but when i run the code in cmd and copy past the url , enterance.html works except image and contact.html transfering – Sara Aug 03 '21 at 01:33
  • I'm not very experienced in using "flask", however I suggest you try the following: create a folder called "static" in the working directory (at the same level as "templates" so to speak.) Then move the image to inside the folder you just created. Now change the src value of the image tag in the html file to: "{{ url_for('static', filename = 'Hajar.png') }}" It must be wrapped in quotes as I wrote. As for the contact page, I am modifying my answer by providing you with an alternative method – Marco Gatto Aug 03 '21 at 02:12