1
0
forked from spitkov/sxbin
This commit is contained in:
realcgcristi 2024-09-09 10:25:58 +03:00
parent 118cb2c365
commit 6db56ef6aa
2 changed files with 86 additions and 1 deletions

15
app.py
View File

@ -109,10 +109,13 @@ def shorten_url():
@app.route('/<vanity>', methods=['GET'])
def redirect_vanity(vanity):
target = data_store.get(vanity)
if target:
if target['type'] == 'pastebin':
return render_template(f'{vanity}.html')
elif target['type'] == 'file':
file_path = os.path.join(app.config['UPLOAD_FOLDER'], f'{vanity}_{target["filename"]}')
file_info = {
'name': target['filename'],
@ -120,12 +123,22 @@ def redirect_vanity(vanity):
'modified_at': datetime.fromtimestamp(os.path.getmtime(file_path)).strftime('%Y-%m-%d %H:%M:%S'),
'url': url_for('download_file', vanity=vanity)
}
return render_template('file.html', **file_info)
return render_template('404.html'), 404
@app.route('/<vanity>/raw', methods=['GET'])
def rawvanity(vanity):
def raw_vanity(vanity):
target = data_store.get(vanity)
if target:
if target['type'] == 'pastebin':
return render_template(f'{vanity}raw.html')
return render_template('404.html'), 404
if __name__ == '__main__':
app.run(debug=True,port=7123)

72
templates/404.html Normal file
View File

@ -0,0 +1,72 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>404 Not Found</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #121212;
color: #e0e0e0;
margin: 0;
padding: 0;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
text-align: center;
}
.container {
background: #1e1e1e;
border-radius: 8px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
padding: 20px;
max-width: 600px;
width: 100%;
}
h1 {
margin: 0;
font-size: 100px;
color: #f5f5f5;
}
p {
margin: 10px 0;
font-size: 18px;
color: #e0e0e0;
}
a {
color: #007bff;
text-decoration: none;
font-weight: bold;
}
a:hover {
text-decoration: underline;
}
.footer {
margin-top: 20px;
font-size: 14px;
color: #99aab5;
}
.footer a {
color: #61afef;
text-decoration: none;
}
.footer a:hover {
text-decoration: underline;
}
</style>
</head>
<body>
<div class="container">
<h1>404</h1>
<p>Oops! The page youre looking for doesnt exist.</p>
<p><a href="/">Go back to the homepage</a></p>
</br>
</br>
</br>
</br>
<p>Source code on: </p><a href="https://github.com/realcgcristi/aCloud" target="_blank">GitHub</a> | <a href="https://git.spitkov.hu/cgcristi/aCloud" target="_blank">Spitkov's Git</a>
</div>
</body>
</html>