Unsupported Page Added

This commit is contained in:
cleontay 2023-05-30 21:07:38 +08:00
parent 3195c2c689
commit b267e81b4a
6 changed files with 194 additions and 89 deletions

View File

@ -27,6 +27,7 @@ def encode():
@app.route("/encoding", methods=['POST'])
def encoding():
try:
file = request.files['origin']
b2c = [int(x) for x in request.form.getlist("b2c")]
# b2c = [int(request.form['b2c'])]
@ -61,6 +62,8 @@ def encoding():
session['txt2'] = "encoded_" + file.filename
return redirect("/encode_result")
except:
return redirect("/unsupported")
@app.route('/encode_result')
def encode_result():
@ -76,6 +79,7 @@ def decode():
@app.route("/decoding", methods=['POST'])
def decoding():
try:
file = request.files['encoded_file']
b2c = [int(x) for x in request.form.getlist("b2c")]
if file.filename != "":
@ -96,6 +100,8 @@ def decoding():
session["txt"] = file.filename
return redirect("/decode_result")
except:
return redirect("/unsupported")
@app.route('/decode_result')
def decode_result():
@ -104,6 +110,10 @@ def decode_result():
else:
return redirect("/decode")
@app.route('/unsupported')
def unsupported():
return render_template('unsupported.html')
@app.route('/get_session')
def get_session():
session_data = dict(session)

View File

@ -8,6 +8,11 @@
<title>Decode</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.4/jquery.min.js"></script>
<style>
* {
padding: 0px;
margin: 0px;
}
.drop-zone {
background-color: #f8f8f8;
border: 2px dashed #cccccc;
@ -55,7 +60,8 @@
color: white;
cursor: pointer;
}
table{
table {
width: 400px;
margin: 10px auto;
}
@ -63,8 +69,10 @@
</head>
<body>
<a style="text-decoration: none; color: white; display: inline-block; padding: 14px 16px; background-color: gray;" href="/">< Back</a>
<div class="form-container">
<form action="/decoding" method="POST" enctype = "multipart/form-data">
<form action="/decoding" method="POST" enctype="multipart/form-data">
<div class="drop-zone" id="dropZone">
<div class="upload-icon">&#8681;</div>
<div class="upload-text">Drag and drop an image here or click to browse</div>

View File

@ -8,6 +8,7 @@
<title>RESULT</title>
</head>
<body>
<a style="text-decoration: none; color: white; display: inline-block; padding: 14px 16px; background-color: gray;" href="/decode">< Back</a>
</body>
<script>
@ -16,27 +17,27 @@
$.get('/get_session', function(response) {
if(response.hasOwnProperty("image")){
console.log(response)
var html_content = `<section>
<div>
<h1>Decoded</h1>
var html_content = `<section style="margin: 100px auto; width:50%; height:50%; text-align:center;">
<div style="width:100%; height:100%; text-align:center;">
<h1 style="height:15%; width:90%; padding: 5%">Decoded</h1>
<img src="upload/` + response["image"] + `" alt="Image Not Found">
</div>
<div>
<h1>Secret Text:</h1>
<p>` + response["payload"] + `</p>
<div style="width:100%; height:100%; text-align:center;">
<h1 style="height:15%; width:90%; padding: 5%">Secret Text:</h1>
<p style="color: red">` + response["payload"] + `</p>
</div>
</section>`
$("body").append(html_content)
}
else if(response.hasOwnProperty("wav")){
var html_content = `<section>
<h1>Decoded</h1>
var html_content = `<section style="margin: 100px auto; width:50%; height:50%; text-align:center;">
<h1 style="height:15%; width:90%; padding: 5%">Decoded</h1>
<audio controls>
<source src="upload/` + response["wav"] + `" type="audio/wav">
Your browser does not support the audio element.
</audio>
<div>
<h1>Secret Text:</h1>
<h1 style="height:15%; width:90%; padding: 5%">Secret Text:</h1>
<p>` + response["payload"] + `</p>
</div>
</section>`
@ -46,13 +47,13 @@
fetch("upload/" + response["txt"])
.then(res => res.text())
.then(data => {
var html_content = `<section>
<div>
<h1>Decoded</h1>
<textarea>` + data + `</textarea>
var html_content = `<section style="margin: 100px auto; width:50%; height:50%; text-align:center;">
<div style="width:100%; height:100%; text-align:center;">
<h1 style="height:15%; width:90%; padding: 5%">Decoded</h1>
<textarea style="height:75%; width:90%; padding: 5%">` + data + `</textarea>
</div>
<div>
<h1>Secret Text:</h1>
<div style="width:100%; height:100%; text-align:center;">
<h1 style="height:15%; width:90%; padding: 5%">Secret Text:</h1>
<p>` + response["payload"] + `</p>
</div>
</section>`

View File

@ -8,6 +8,11 @@
<title>Encode</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.4/jquery.min.js"></script>
<style>
*{
padding: 0px;
margin: 0px;
}
.drop-zone {
background-color: #f8f8f8;
border: 2px dashed #cccccc;
@ -65,6 +70,8 @@
</head>
<body>
<a style="text-decoration: none; color: white; display: inline-block; padding: 14px 16px; background-color: gray;" href="/">< Back</a>
<div class="form-container">
<form action="/encoding" method="POST" enctype = "multipart/form-data">
<div class="drop-zone" id="dropZone">

View File

@ -6,8 +6,20 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<title>RESULT</title>
<style>
*{
padding: 0px;
margin: 0px;
}
html, body{
width: 100%;
height: 100%;
}
</style>
</head>
<body>
<a style="text-decoration: none; color: white; display: inline-block; padding: 14px 16px; background-color: gray;" href="/encode">< Back</a>
</body>
<script>
@ -16,13 +28,13 @@
$.get('/get_session', function(response) {
if(response.hasOwnProperty("image")){
console.log(response)
var html_content = `<section style="display: flex; justify-content: flex-start;">
<div>
<h1>Original</h1>
var html_content = `<section style="margin: 100px auto; width:50%; height:50%; display: flex; justify-content: space-between;">
<div style="border: 1px solid black; width:100%; height:100%; text-align:center;">
<h1 style="height:15%; width:90%; padding: 5%">Original</h1>
<img src="upload/` + response["image"] + `" alt="Image Not Found">
</div>
<div>
<h1>Encoded</h1>
<div style="border: 1px solid black; width:100%; height:100%; text-align:center;">
<h1 style="height:15%; width:90%; padding: 5%">Encoded</h1>
<img src="upload/` + response["image2"] + `" alt="Image Not Found">
</div>
@ -30,16 +42,16 @@
$("body").append(html_content)
}
else if(response.hasOwnProperty("wav")){
var html_content = `<section style="display: flex; justify-content: flex-start;">
<div>
<h1>Original</h1>
var html_content = `<section style="margin: 100px auto; width:50%; height:50%; display: flex; justify-content: space-between;">
<div style="border: 1px solid black; width:100%; height:100%; text-align:center;">
<h1 style="height:15%; width:90%; padding: 5%">Original</h1>
<audio controls>
<source src="upload/` + response["wav"] + `" type="audio/wav">
Your browser does not support the audio element.
</audio>
</div>
<div>
<h1>Encoded</h1>
<div style="border: 1px solid black; width:100%; height:100%; text-align:center;">
<h1 style="height:15%; width:90%; padding: 5%">Encoded</h1>
<audio controls>
<source src="upload/` + response["wav2"] + `" type="audio/wav">
Your browser does not support the audio element.
@ -56,14 +68,14 @@
fetch("upload/" + response["txt2"])
.then(res2 => res2.text())
.then(data2 => {
var html_content = `<section style="display: flex; justify-content: flex-start;">
<div>
<h1>Original</h1>
<textarea>` + data + `</textarea>
var html_content = `<section style="margin: 100px auto; width:50%; height:50%; display: flex; justify-content: space-between;">
<div style="border: 1px solid black; width:100%; height:100%; text-align:center;">
<h1 style="height:15%; width:90%; padding: 5%">Original</h1>
<textarea style="height:77%; width:100%">` + data + `</textarea>
</div>
<div>
<h1>Encoded</h1>
<textarea>` + data2 + `</textarea>
<div style="border: 1px solid black; width:100%; height:100%; text-align:center;">
<h1 style="height:15%; width:90%; padding: 5%">Encoded</h1>
<textarea style="height:77%; width:100%">` + data2 + `</textarea>
</div>
</section>`

View File

@ -0,0 +1,67 @@
<!DOCTYPE html>
<html>
<head>
<title>File Unsupported</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f2f2f2;
margin: 0;
padding: 0;
display: flex;
align-items: center;
justify-content: center;
height: 100vh;
}
.container {
text-align: center;
background-color: #fff;
padding: 30px;
border-radius: 5px;
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}
h1 {
color: #333;
font-size: 28px;
margin-bottom: 20px;
}
p {
color: #777;
font-size: 18px;
margin-bottom: 30px;
}
.icon {
width: 120px;
height: 120px;
border-radius: 50%;
background-color: red;
margin: 0px auto;
display: flex;
align-items: center;
justify-content: center;
font-size: 60px;
color: white;
text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.4);
}
.icon::before {
content: "X";
}
</style>
</head>
<body>
<div class="container">
<h1>File Unsupported</h1>
<p>We're sorry, but the file format you uploaded is not supported.</p>
<div class="icon"></div>
<a style="text-decoration: none; color: black; display: inline-block; margin: 20px 0px 0px; padding: 14px 16px;" href="#" onclick="history.back()">< Back</a>
</div>
</body>
</html>