年度报告新增分享功能

This commit is contained in:
shuaikangzhou 2024-01-20 21:59:30 +08:00
parent 1353c3659c
commit 32712426a9
2 changed files with 48 additions and 3 deletions

View File

@ -10,6 +10,7 @@
<link rel="stylesheet" href="https://memotrace.lc044.love/static/css/fullpage.min.css" />
<script src="https://code.jquery.com/jquery-3.6.4.min.js"></script>
<script src="https://memotrace.lc044.love/static/js/fullpage.min.js"></script>
<script src="https://davidshimjs.github.io/qrcodejs/qrcode.min.js"></script>
</head>
<body>
<div id="snow"></div>
@ -228,13 +229,53 @@
<div id="calendar-chart" class="calendar-chart"></div>
</div>
</div>
<div class="section">
<div class="section" style="text-align: center;display:flex;justify-content: center;align-items: center;">
<h1 style="text-align: center;">敬请期待</h1>
<h1>Upload HTML and Display QR Code</h1>
<button onclick="confirmUpload()">Upload and Display QR Code</button>
<div id="qrcode"></div>
</div>
<!-- Add more sections as needed -->
</div>
<script>
function confirmUpload() {
var userConfirmed = confirm("注意!!!\n本页面将会上传至服务器别可通过链接查看该网页该操作不会上传您的其他任何信息页面将在下个版本更新之后删除请注意链接生效时间。\n点击“确认”代表您同意上传至服务器如不同意请点击取消");
if (userConfirmed) {
// User clicked OK, perform the upload and display QR code
uploadAndDisplayQRCode();
} else {
// User clicked Cancel or closed the dialog
alert("Upload canceled.");
}
}
function uploadAndDisplayQRCode() {
// Simulate a GET request to the server endpoint
fetch('http://127.0.0.1:21314/upload')
.then(response => response.json())
.then(data => {
if (data.success) {
displayQRCode(data.url);
} else {
alert('Error: Unable to fetch data from the server.');
}
})
.catch(error => {
console.error('Error:', error);
alert('Error: Unable to fetch data from the server.');
});
}
function displayQRCode(url) {
var qrcode = new QRCode(document.getElementById("qrcode"), {
text: url,
width: 128,
height: 128
});
}
</script>
<script>
// JavaScript 代码用于生成聊天内容和雪花动画
document.addEventListener('DOMContentLoaded', function () {

View File

@ -2,7 +2,7 @@ import os
import sys
import requests
from flask import Flask, render_template, send_file
from flask import Flask, render_template, send_file, jsonify, make_response
from app.DataBase import msg_db
from app.analysis import analysis
@ -120,7 +120,11 @@ def upload():
}
response = requests.post(api_url, data=data)
print(response.json())
return response.json()
response = make_response(response.json())
response.headers.add('Access-Control-Allow-Origin', '*') # Replace '*' with specific origins if needed
response.headers.add('Content-Type', 'application/json')
return response
@app.route('/wordcloud/<who>/')