Click here to Skip to main content
15,940,550 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I see this on web, I want to try myself but stock

- .py
(can get sql data and pass on index_test_0203.html)
import mysql.connector
import webbrowser
import time
import pymysql
from flask import Flask,render_template,request 

app = Flask(__name__)

mydb = mysql.connector.connect(
mycursor = mydb.cursor()

# below one can work that exectue pyscript with fixed P_ID = 'en_1-01'
# mycursor.execute("SELECT P_TITLE,P_DESC  FROM webpage WHERE P_ID = 'en_1-01'")  

# this one won't work, want to get text from .html
mycursor.execute("SELECT P_TITLE,P_DESC  FROM webpage WHERE P_ID = "+request.args["P_ID"])                     
myresult = mycursor.fetchall()


def index():
    return render_template("index_test_0203.html", myresult = myresult)

if __name__ == "__main__":

- index_test_0203.html
(can get text by flask from url to html document.write(p) )
but lacking pass that text to .py as certain P_ID to search, and activate .py
<!DOCTYPE html>
    <script type="text/javascript">
        const queryString =;
        const urlParams = new URLSearchParams(queryString);
        for (const p of urlParams) {
      <p> this is {{myresult}}</p>


[(demo pic) the activate order]( please take a look

[(the original pic)](

I will put both .py and .html on cloud server

What I have tried:

- main idea:
how to trigger/activate .py file from .html url, such as ``

what I have studied for now is that maybe ajax or flask could help, if get any suggestion just let me know, I'm happy to learn new thing, and in order to fix this problem
Updated 3-Feb-23 7:25am
Richard MacCutchan 3-Feb-23 4:40am    
You need a webserver running on that can service that request. But your question is not very clear.
j ton 3-Feb-23 4:52am    
I both upload index_test_0203.html and .py to WinSCP, the cloud server, but just question on how to trigger/activate .py file from .html url, such as ``
Richard MacCutchan 3-Feb-23 4:59am    
That is just a repeat of what you have posted above, and my answer remains the same. You need to explain exactly what the problem is.

Yes I trieed this solution in CMD prompt and this is the answer that it gave me, it gave me this as a result not to sure but I tried to execute the code and it didn't properly work out.

The code you provided would just give me a repeated error in the command prompt and tell me how the app.route is not a recognized interal or external command and there is no batch file..
Share this answer
I suggest you take a look at Welcome to Flask — Flask Documentation (2.2.x)[^], and work through the tutorial.
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900