Creating a Database

I am creating a survey and the project mode is set to HTML, CSS, and JS. I would like to create a Replit database that stores the results. I tried creating a database in Python, but it doesn’t work because the document language is set to HTML, CSS, and JS. How can I solve this problem?

1 Like

You could host a flask (python) website instead. It shouldn’t be that hard to setup to serve HTML/CSS/JS files IIRC.

1 Like

I am new to coding. How does that work?

from flask import Flask, render_template

app = Flask(__name__, "/static/")

def index():
  # Make sure you have a folder named "templates" and there is a file named "index.html" inside
  # of it. If you have any CSS files, put them in a folder (in the root directory) called "static" and link
  # it in the HTML file as "../static/style.css" replacing "style" for the name of your CSS file.
  return render_template("index.html")"", 82)

Check out the 100 days of code python course on YouTube for tutorials on Flask.

if you need more help i can help you with it

Why the "/static/"?

The static_url_path. I don’t think it’s needed if you use render_template but I still put it in.

1 Like

You put all files you want flask to load on startup in the static folder


Oh I didn’t know you could do that thanks!

If we use render_template then the default path is /templates/ for storing html files.

/static/ is by default used for images/css files iirc

Yes, I know that… That’s why I said to create a folder called templates and static…

I have a similar issue, I made a string of website pages as a string of puzzles, there’s a timer that I want to save into like a txt file or something like that, a long with there name that they type in, this is for a school project btw, so I want to find a way to save there name and the time in a separate file that stays there permanently unless deleted. But my files arnt connected to run off separate folders, and it’s a pain to go through all the html files and redirect them, I mean I could but it’ll take a long time.

You could just create a separate Repl that has a server. Then within the ‘puzzle’, whatever the start page is can send POST request with the name to the other Repl with the server (which should then log the name and the time). Then on completion send another POST request to ‘end’ the ‘attempt’ and retrieve the time taken. Of course given the new .dev URLs, you would either need to deploy or have the editor for both Repls open which is not ideal.

thanks for your advice, if possible, i want other people to run it on there computers but i cant deploy because of the subscribtion needed, is there some way to do that or do i have to make a deployment