Help linking html data to be saved in another file to view later

I have a repl that’s a string of puzzles and that the user is timed on how fast they can get through them all (this is a school project btw). I want to be able to save the amount of time and their name which they enter afterwards, in a separate file for me and the teacher to view and I want them to stay there permanently afterwards unless deleted, I know about flask but I don’t know how to move and edit things to work with flask b/c my pages arnt made to work separately with the html files in a separate folder from the css and js files in another folder. trust me I tried/tested them by putting the html files into a folder separate from the css and js files in another folder. any help or suggestions would be greatly appreciated.

Just set up a Flask application that handles both the user interface and the backend logic for storing the data.

Also, remember to create the folders following the flask structure

/your_project
    /static
        /css
            - style.css
        /js
            - script.js
    /templates
        - puzzle.html
    - app.py

Your app.py will initialize the Flask app and handle routes. For example:

from flask import Flask, render_template, request
import csv

app = Flask(__name__)

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

@app.route('/submit', methods=['POST'])
def submit():
    name = request.form['name']
    time = request.form['time']

    with open('results.csv', 'a', newline='') as file:
        writer = csv.writer(file)
        writer.writerow([name, time])

    return 'Data saved!'

if __name__ == '__main__':
    app.run(debug=True)
2 Likes

:wave: Welcome to the forums, @DavidMcCleary!

It seems that this post is asking for answers to a school assignment. It is against the Replit Ask community standards to ask for homework assistance.