commit ce6b469c3e0cb8645083d84e8b6f4025f3c79d98
parent 43f716e68ecdca5d3e1dbdf000a7a83806ef6ab2
Author: parazyd <parazyd@dyne.org>
Date: Tue, 9 Feb 2021 06:09:06 +0100
Add support for cli args and bjoern.
Diffstat:
M | blck.py | | | 28 | +++++++++++++++++++++------- |
1 file changed, 21 insertions(+), 7 deletions(-)
diff --git a/blck.py b/blck.py
@@ -12,12 +12,6 @@ from string import ascii_uppercase, ascii_lowercase
from flask import Flask, render_template, redirect, request
APP = Flask(__name__)
-# configure blck's behavior here
-EPHEMERAL = True
-PASTEBIN = False
-if not PASTEBIN:
- import re
-
@APP.route("/", methods=['GET', 'POST'])
def main():
@@ -81,4 +75,24 @@ def genid(size=4, chars=ascii_uppercase + ascii_lowercase):
if __name__ == '__main__':
- APP.run(host="127.0.0.1", port=5000)
+ from argparse import ArgumentParser
+ parser = ArgumentParser()
+ parser.add_argument('--pastebin', default=False, action='store_true',
+ help='Use as pastebin rather than URL shortener')
+ parser.add_argument('--noephemeral', default=False, action='store_true',
+ help='Do not run in ephemeral mode')
+ parser.add_argument('-l', default='localhost', help='Listen host')
+ parser.add_argument('-p', default=5000, help='Listen port')
+ parser.add_argument('-d', default=False, action='store_true', help='Debug')
+ args = parser.parse_args()
+
+ EPHEMERAL = not args.noephemeral
+ PASTEBIN = args.pastebin
+ if not PASTEBIN:
+ import re
+
+ if args.d:
+ APP.run(host=args.l, port=args.p, threaded=True, debug=args.d)
+ else:
+ from bjoern import run
+ run(APP, args.l, args.p)