Fixed Multiline Support and added the start of a UI
This commit is contained in:
parent
0dc25e5da2
commit
5868dee2c9
15
paste.py
15
paste.py
@ -3,6 +3,7 @@
|
||||
from flask import Flask, request
|
||||
import random, string
|
||||
from pathlib import Path
|
||||
from pprint import pprint
|
||||
|
||||
# Basic settings for paste
|
||||
|
||||
@ -38,7 +39,9 @@ def doesPasteExist(pasteName):
|
||||
|
||||
def writePaste(pasteName, pasteData):
|
||||
pasten = pasteDir / pasteName
|
||||
with pasten.open('w') as f: f.write(pasteData + '\n')
|
||||
tmpData = pasteData.split('\n')
|
||||
for line in tmpData:
|
||||
with pasten.open('a') as f: f.write(line + '\n')
|
||||
|
||||
|
||||
|
||||
@ -49,7 +52,7 @@ doesDirExist()
|
||||
# https://paste.benjamyn.love/CBynvvjwDK
|
||||
|
||||
app = Flask(__name__)
|
||||
app.config['DEBUG'] = False
|
||||
app.config['DEBUG'] = True
|
||||
|
||||
@app.route('/', methods=['POST', 'GET'])
|
||||
def index():
|
||||
@ -59,12 +62,15 @@ def index():
|
||||
else:
|
||||
return "Nothing to see here ;)"
|
||||
elif request.method == "POST":
|
||||
data = request.get_data()
|
||||
data = request.get_data().decode()
|
||||
if "Submit+Query" in data:
|
||||
data = request.form['textarea']
|
||||
name = randomName()
|
||||
while doesPasteExist(name):
|
||||
name = randomName()
|
||||
else:
|
||||
writePaste(name, data.decode())
|
||||
print("Writing: " + data)
|
||||
writePaste(name, data)
|
||||
return hostedURL + name
|
||||
|
||||
|
||||
@ -75,6 +81,7 @@ def getPaste(path):
|
||||
print("Checking " + str(pasten))
|
||||
if pasten.is_file():
|
||||
with pasten.open() as f: data = f.read()
|
||||
print(data)
|
||||
return data
|
||||
else:
|
||||
return "No paste found"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user