I'm setting up a website and want it to run a python script in html action the question is that my browser is interpreting the script as if it were a .py file for download.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Cadastro</title>
<link rel="stylesheet" href="bootstrap/css/bootstrap.min.css">
<style>
.menunav, .navbar-brand{
color:white;
}
body {
background-color:#e0e0e0;
}
#painel{
width:30%;
height:30%;
margin-left:36%;
margin-top:10%;
}
</style>
</head>
<body>
<nav class="navbar navbar-dark bg-primary navbar-fixed-top">
<div class="container">
<a class="navbar-brand" href="index.html" >pyagenda</a>
<ul class="nav navbar-nav">
<li class="nav-item">
<a href="index.html" class="menunav">Inicio</a>
</li>
<li class="nav-item">
<a href="entrar.html" class="menunav">Entrar</a>
</li>
<li class="nav-item">
<a href="atualizar.html" class="menunav">Atualizações</a>
</li>
</ul>
</div>
</nav>
<div class="container" id="painel">
<div class="panel panel-primary">
<div class="panel-heading">
Cadastro:
</div>
<div class="panel-body">
<form method="POST" action="cgi-bin/cadastrar.py">
<div class="form-group">
<label>Usuario:</label>
<input type="text" class="form-control" maxlength="30" placeholder="Digite seu Usuario" name="usuario">
</div>
<div class="form-group">
<label>Email:</label>
<input type="email" class="form-control" maxlength="100" placeholder="Digite seu Email" name="email">
</div>
<div class="form-group">
<label>Senha:</label>
<input type="password" class="form-control" maxlength="10" placeholder="Digite Sua Senha" name="pass">
</div>
<div class="form-group">
<label>Nome:</label>
<input type="text" class="form-control" maxlength="80" placeholder="Digite Seu Nome" name="nome">
</div>
<div class="form-group">
<button class="btn btn-primary" type="submit">Cadastrar</button>
</div>
</form>
</div>
</div>
</div>
</body>
</html>
html script
#!/usr/bin/python
import cgi
import mysql.connector
#construtores do form html
cadastro = cgi.FieldStorage()
usu = cadastro.getvalue("usuario")
senha = cadastro.getvalue("pass")
em = cadastro.getvalue("email")
nome = cadastro.getvalue("nome")
#código mysql
conn = mysql.connector.connect(user="root",password="root",host="localhost",database="agenda")
cursor = conn.cursor()
query = ("""INSERT INTO cadastros
(usuario,senha,email,nome)
VALUES (%s,%s,%s,%s)""")
valores = (usu,senha,em,nome)
cursor.execute(query,valores)
conn.commit()
cursor.close()
conn.close()
sign up.py
I use Ubuntu as an operating system