How to call the root page in a Fast API app from another route

I am very new to FastApi and I know a little HTML.

I have a root route in FastAPI that connects to a MySql db and return a couple of rows from the db.

import mysql.connector
from typing import Annotated
from fastapi import FastAPI, HTTPException, Request, BackgroundTasks, Depends, Form
from fastapi.middleware.cors import CORSMiddleware
from fastapi.templating import Jinja2Templates
from fastapi.responses import HTMLResponse

from schemas import User, Role, ActionPerformed, ProcedureExecuted, Persons
import database as db

@app.get("/")
async def home(request: Request):
    """ Show the procedures executed """
    connection = db.get_db()
    cursor = connection.cursor()
    query = "SELECT * FROM proc_executes ORDER BY Proc_Procedure"
    cursor.execute(query)
    proc_exec = cursor.fetchall()
    connection.close()

    for proc in proc_exec:
        print(f"Single Proc Exec: {proc}")

    return templates.TemplateResponse("home.html", {
        "request": request,
        "proc_exec": proc_exec,
    })

The html for home.html:


{% block content %}
This is the <i>Home</i> page for the <b>Thesis Tracking</b> app
<br/><br/>

<div class="ui input">
  <input type="text" placeholder="Search persons" spellcheck="false" data-ms-editor="true">
</div>
<br/>
<br/>
https://semantic-ui.com/elements/button.html
<br/>
<br/>
<br/>

<div class="ui button" tabindex="0">
  Focusable
</div>
</p>

<table class="ui celled table">
  <thead>
    <tr>
        <th>Procedure</th>
        <th>Source</th>
        <th>Date</th>
        <th>Time</th>
    </tr>
  </thead>
  <tbody>
        <b>Date and time of procedures executed</b>
      {% for proc in proc_exec %}

    <tr>
      <td>{{ proc.1 }}</td>
      <td>{{ proc.2 }}</td>
      <td>{{ proc.3 }}</td>
      <td>{{ proc.4 }}</td>
    </tr>
      {% endfor %}
  </tbody>
</table>

{% endblock %}

I have another route, persons, that return the list of all persons from the same db:

@app.get("/persons")
async def read_persons(request: Request):
    connection = db.get_db()
    cursor = connection.cursor()
    query = "SELECT * FROM persons"
    cursor.execute(query)
    v_persons = cursor.fetchall()
    connection.close()

    for v_person in v_persons:
        print(f"Single person Exec: {v_person}")

    return templates.TemplateResponse("persons.html", {
        "request": request,
        "persons": v_persons,
    })

The persons.html looks like this:

{% extends "layout.html" %}

{% block content %}
This is the <i>Persons</i> page for the <b>Thesis Tracking</b> app
<br/>
<div>
    <button class="ui button">
        Home
    </button>
</div>
<br/><br/>

<table class="ui celled table">
  <thead>
    <tr>
        <th>Procedure</th>
        <th>Source</th>
        <th>Date</th>
        <th>Time</th>
    </tr>
  </thead>
  <tbody>
        <b>Persons</b>
      {% for person in persons %}
    <tr>
      <td>{{ person.1 }}</td>
      <td>{{ person.2 }}</td>
      <td>{{ person.3 }}</td>
      <td>{{ person.4 }}</td>
    </tr>
      {% endfor %}
  </tbody>
</table>

{% endblock %}

When the user clicks the “Home” button, the home route must be called i.e. displays home.html.

I have tried several resources:
How to navigate through FastAPI routes by clicking on HTML button in Jinja2 Templates?
https://fastapi.tiangolo.com/tutorial/request-forms/
FastAPI equivalent of Flask’s request.form, for agnostic forms

When I try to implement any of the ways to call an HTML page, I get the message “Method not allowed”.

Can anyone please point me to a practical example to call the home.html from persons.html when the user clicks on the “Home” Button.

Thanks you, in advance.

Regards,

Phlip

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật