Added in templates for adding/reading pastes

This commit is contained in:
Benjamyn Love 2018-12-09 01:14:04 +11:00
parent 5868dee2c9
commit 2334bbccf9
3 changed files with 58 additions and 5 deletions

View File

@ -1,6 +1,6 @@
#!/usr/bin/python3
#!/usr/bin/python3.6
from flask import Flask, request
from flask import Flask, request, render_template
import random, string
from pathlib import Path
from pprint import pprint
@ -52,7 +52,7 @@ doesDirExist()
# https://paste.benjamyn.love/CBynvvjwDK
app = Flask(__name__)
app.config['DEBUG'] = True
app.config['DEBUG'] = False
@app.route('/', methods=['POST', 'GET'])
def index():
@ -60,7 +60,7 @@ def index():
if allowListing == True:
return "FileList"
else:
return "Nothing to see here ;)"
return render_template("post.html")
elif request.method == "POST":
data = request.get_data().decode()
if "Submit+Query" in data:
@ -82,7 +82,7 @@ def getPaste(path):
if pasten.is_file():
with pasten.open() as f: data = f.read()
print(data)
return data
return render_template("read.html", data=data)
else:
return "No paste found"

27
templates/post.html Normal file
View File

@ -0,0 +1,27 @@
<!DOCTYPE html>
<html>
<head>
<title>PasteBen</title>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
</head>
<body>
<center>
<h1>PasteBen</h1>
<div class="container container-fluid">
<form action="http://paste.benjamyn.love" method="post" class="card">
<textarea name="textarea" style="height:600px;"></textarea>
<input type="submit" name="data" class="btn btn-outline-secondary">
</form>
</div>
</center>
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" crossorigin="anonymous"></script>
</body>
</html>

26
templates/read.html Normal file
View File

@ -0,0 +1,26 @@
<!DOCTYPE html>
<html>
<head>
<title>PasteBen</title>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
</head>
<body>
<center>
<h1>PasteBen</h1>
<div class="container container-fluid">
<form class="card">
<textarea name="textarea" style="height:600px;" >{{data}}</textarea>
</form>
</div>
</center>
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" crossorigin="anonymous"></script>
</body>
</html>