text: Title: On Debug Mode my function is called twice
  Body: ```py
  
  import shutil
  import os
  from flask import Flask, render_template, request
  from datetime import datetime
  from os.path import isfile, join
  from sqlite3 import connect
  
  class Server(Flask):
    def __init__(self, *args, **kwargs):
      super().__init__(*args, **kwargs)
      
      self.db_path = join("back-end", "database" ,"news.db")
      
      #Routes
      @self.route("/")
      @self.route("/home")
      def home():
        return render_template("home.html")
      
      @self.route("/about")
      def about():
        return render_template("about.html")
      
      @self.route("/table")
      def table():
        return render_template("table.html")
      
      @self.route("/sabah")
      def sabah():
        return render_template("sabah.html")
  
      @self.route("/news")
      def news():
        pass
      
      @self.route("/science")
      def science():
        pass
      #Functionality
      
      @self.template_global("getsemester")
      def gettime()->str:
        """This function gets current time and determines
        the semester to show."""
        now = datetime.now()
  
        if isfile("static/cedvel/cedvel.pdf"):
          
          if datetime(now.year, 9, 15) <= now < datetime(now.year+1, 2, 16):  
            return f"{now.year} PAYIZ SEMESTERİ üçün nəzərdə tutulub!"
          
          elif datetime(now.year, 2, 15) <= now < datetime(now.year, 6, 15):
            return f"{now.year} YAZ SEMESTERİ üçün nəzərdə tutulub!"
          
          else:
            return  "Hal hazırda yay tetili ilə əlaqadər cedvəl hazır deyil."
            
        else:
          return  "Hal hazırda cədvəl hazır deyil"
      
      @self.template_global("insertnews")
      def insertnews(header:str, main:str, date=datetime.now().strftime("%Y-%m-%d"))->str:
        """this function inserts news to the server"""
        
        print("FUNCTION CALLED!!!!")
        conn = connect(self.db_path)
        curr = conn.cursor()
        
        curr.execute("""
                           INSERT INTO news (header, main, date) VALUES (?, ?, ?)
                           """, (header, main, date))
        
        conn.commit()
        
        #getting latest news id
        id = curr.lastrowid
        print(id)
        
        conn.close()
        
        news_path = join("static", "media", "news", f"NEWS-{id}")
        
        os.makedirs(news_path)
        
        # image = request.files["image"]
        # 
        # image.save(news_path, f"NEWS:{header}-{id}")
        
        return "XƏBƏR BAŞARIYLA YÜKLƏNDİ!"
        
      @self.template_global("deletenews")
      def deletenews(id: int)->str:
        """This function deletes news from server"""
        
        conn = connect(self.db_path)
        
        c = conn.cursor()
  
        c.execute("DELETE FROM news WHERE rowid=?", (id,))
        conn.commit()
  
        conn.close()
        
        news_path = join("static", "media", "news")
        
        #deleting images of deleted news
        for dirpath, dirnames, filenames in  os.walk(news_path):
          if f"NEWS-{id}" in dirnames:
              dir_to_delete = os.path.join(dirpath, f"NEWS-{id}")
              shutil.rmtree(dir_to_delete)
              
        return "XƏBƏRLƏR BAŞARIYLA SİLİNDİ"
              
      
      @self.template_global("getlatestnews")
      def getlatestnews()->list[str, str, str]:
        """this function returns latest 4 news from db"""
  
        conn = connect(self.db_path)
        
        c = conn.cursor()
  
        c.execute("SELECT * FROM news ORDER BY rowid DESC LIMIT 4")
        conn.commit()
  
        print(c.fetchall())
  
        conn.close()
        
      @self.template_global("getnews")
      def getnews()->str:
        pass
      
      insertnews("BASLIQ1", "XEBER1")     
  
  if __name__ == "__main__":
    
    server = Server(
      import_name=__name__,
      template_folder="../front-end/template",
      static_folder="../static")
    
    server.run()
  ```
  
  
  
  <!--
  it works right when i turn off DEBUG mode
  -->
  
  <!--
  it should call my insertnews() function once
  -->
  
  Environment:
  
  - Python version: 3.11.0
   - Flask version: 2.2.2
  