First, we'll create a very simple Python script, using Flask. If you're not familiar with Flask yet, don't worry—we won't get into it in detail here.
Here's an example of an app.py script:
from flask import Flask
import os
app = Flask(__name__, static_folder=os.getcwd())
@app.route('/')
def root():
return app.send_static_file('index.html')
@app.route('/data')
def query():
return 'Todo...'
Here's our HTML with JavaScript (index.html):
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>My Page</title>
</head>
<body>
<h1 id="header">Welcome to my page!</h1>
<form>
<label for="name">Please enter your name:</label>
<input type="text" placeholder="Name here" name="name" id="name" />
<button type="...