skip to Main Content

D

Python Code

import openai


app = Flask(__name__)
app.debug = True

#audio_file= open("/path/to/file/audio.mp3", "rb")
#transcript = openai.Audio.transcribe("whisper-1", audio_file)


@app.route('/')
def hello_flask():
   return render_template('landing.html')


if __name__ == '__main__':
   app.run()

HTML Code of Main Page (landing.html)

<html>
    <head>
        <title>komodo.ai</title>
        <link rel="stylesheet" href="static/styles.css">
        <meta content="AI scribe-based technology that removes the need for manual documentation. Bring the joy of care back to medicine by giving you more time to do what you love." name="description"/>
        <style>
            body {
                text-align: center;
            }
        </style>
    </head>
   <body>
    <div class="page-wrapper">
        <div class="banner_component">
        <h1>Welcome to My Webpage</h1>
        <p>This is the content of my webpage.</p>
        <!-- Other elements and sections of the page -->
      </div>
    </div>
    
    <header>
        <nav>
            <ul>
                <li style="display:inline"><a href="audio.html">Transcribe Here</a></li>
                <li style="display:inline">Item 2</li>
                <li style="display:inline">Item 3</li>
              </ul>
        </nav>
    </header>


    <header>
        <h1>Welcome to our Startup</h1>
        <p>Discover the future with us.</p>
        <a href="/about">Learn More</a>
    </header>
    <div id="Komodo image">
        <img src="{{ url_for('static', filename='Komodo_image.jpeg') }}">

    </div>

      
   </body>


</html>

I’m getting this error: "GET /audio.html HTTP/1.1" 404 –

Seems like for some reason, audio.html isn’t accessed with this line of code: Transcribe Here. It’s strange because audio.html is in the same directory as the landing.html

2

Answers


  1. You need to create the route for the page in app.py. Right now, audio.html is just a file sitting in your templates directory. See the official docs.

    ...
    
    @app.route('/')
    def hello_flask():
        return render_template('landing.html')
    
    @app.route('/audio')
    def audio():
        return render_template('audio.html')
    
    if __name__ == '__main__':
        app.run()
    

    And then change your href to href="/audio"

    Login or Signup to reply.
  2. As correctly pointed from previous answer, Flask works on routes.
    Every page (basically every url) has to be a "route" declared as

    `
    @app.route('/your_route_name')
        def your_route_name():
        your code
    ` 
    

    Main example.

    Index route:

    @app.route("/")
    def index():
        return render_template('index.html')
    

    But also, every call you want to build has to be under a route. Imagine you want to return something by calling an url (as for example works with rest API), you always need to use routing to declare them.

    Also in this page the routing is well explained (the flask documentation is great to start anyway): https://www.geeksforgeeks.org/flask-app-routing/

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search