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?

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")


app.run("0.0.0.0", 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

2 Likes

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…