[Python] How do I connect my pre-exisiting html-css webpages to a python code using Flask?

Discussão em 'Python' iniciado por Stack, Fevereiro 2, 2025.

  1. Stack

    Stack Membro Participativo

    So I had been working on a code for a movie-recommendation site for a school project, which we were supposed to do in Python. It stores a dictionary of movies and takes couple inputs to recommend movies/add new movies etc. I thought of going the extra mile and I designed a html-css website for my code that has a few interlinked pages. The issue is that I can't figure out how to connect my python code to the webpages.

    I haven't used web frameworks like Flask before so I can't figure out how to link it to my index.html file. Also, I don't totally get how app routes work.

    I tried putting in the file path to my html file in the app route () argument but it resulted in an error. And when I put in my html code in the return value, it didn't gi ve me my designed webpage.

    @app.route("/")
    def index():
    return "Hello World!"

    1. What does the url in the () exactly do?
    2. what argument do I pass in the def ()? and what does def actually define?
    3. How do I integrate my pre-existing python code?
    4. Where do I put in my html-css code?

    Continue reading...

Compartilhe esta Página