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
|
from flask import Flask, request
|
||||||
import random, string
|
import random, string
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
from pprint import pprint
|
||||||
|
|
||||||
# Basic settings for paste
|
# Basic settings for paste
|
||||||
|
|
||||||
@ -38,7 +39,9 @@ def doesPasteExist(pasteName):
|
|||||||
|
|
||||||
def writePaste(pasteName, pasteData):
|
def writePaste(pasteName, pasteData):
|
||||||
pasten = pasteDir / pasteName
|
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
|
# https://paste.benjamyn.love/CBynvvjwDK
|
||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
app.config['DEBUG'] = False
|
app.config['DEBUG'] = True
|
||||||
|
|
||||||
@app.route('/', methods=['POST', 'GET'])
|
@app.route('/', methods=['POST', 'GET'])
|
||||||
def index():
|
def index():
|
||||||
@ -59,12 +62,15 @@ def index():
|
|||||||
else:
|
else:
|
||||||
return "Nothing to see here ;)"
|
return "Nothing to see here ;)"
|
||||||
elif request.method == "POST":
|
elif request.method == "POST":
|
||||||
data = request.get_data()
|
data = request.get_data().decode()
|
||||||
|
if "Submit+Query" in data:
|
||||||
|
data = request.form['textarea']
|
||||||
name = randomName()
|
name = randomName()
|
||||||
while doesPasteExist(name):
|
while doesPasteExist(name):
|
||||||
name = randomName()
|
name = randomName()
|
||||||
else:
|
else:
|
||||||
writePaste(name, data.decode())
|
print("Writing: " + data)
|
||||||
|
writePaste(name, data)
|
||||||
return hostedURL + name
|
return hostedURL + name
|
||||||
|
|
||||||
|
|
||||||
@ -75,6 +81,7 @@ def getPaste(path):
|
|||||||
print("Checking " + str(pasten))
|
print("Checking " + str(pasten))
|
||||||
if pasten.is_file():
|
if pasten.is_file():
|
||||||
with pasten.open() as f: data = f.read()
|
with pasten.open() as f: data = f.read()
|
||||||
|
print(data)
|
||||||
return data
|
return data
|
||||||
else:
|
else:
|
||||||
return "No paste found"
|
return "No paste found"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user