Add pathod --noapi to turn off the service API.
This commit is contained in:
parent
190392ea13
commit
a950a4d7a3
|
@ -5,24 +5,25 @@ import version, rparse, utils
|
|||
logging.basicConfig(level="DEBUG")
|
||||
app = Flask(__name__)
|
||||
|
||||
@app.route('/api/info')
|
||||
def api_info():
|
||||
return jsonify(
|
||||
version = version.IVERSION
|
||||
)
|
||||
def api():
|
||||
@app.route('/api/info')
|
||||
def api_info():
|
||||
return jsonify(
|
||||
version = version.IVERSION
|
||||
)
|
||||
|
||||
|
||||
@app.route('/api/log')
|
||||
def api_log():
|
||||
return jsonify(
|
||||
log = app.config["pathod"].get_log()
|
||||
)
|
||||
@app.route('/api/log')
|
||||
def api_log():
|
||||
return jsonify(
|
||||
log = app.config["pathod"].get_log()
|
||||
)
|
||||
|
||||
|
||||
@app.route('/api/clear_log')
|
||||
def api_clear_log():
|
||||
app.config["pathod"].clear_log()
|
||||
return "OK"
|
||||
@app.route('/api/clear_log')
|
||||
def api_clear_log():
|
||||
app.config["pathod"].clear_log()
|
||||
return "OK"
|
||||
|
||||
|
||||
@app.route('/')
|
||||
|
|
|
@ -150,7 +150,7 @@ class Pathod(tcp.TCPServer):
|
|||
LOGBUF = 500
|
||||
def __init__( self,
|
||||
addr, ssloptions=None, prefix="/p/", staticdir=None, anchors=None,
|
||||
sizelimit=None, noweb=False, nocraft=False
|
||||
sizelimit=None, noweb=False, nocraft=False, noapi=False
|
||||
):
|
||||
"""
|
||||
addr: (address, port) tuple. If port is 0, a free port will be
|
||||
|
@ -166,9 +166,10 @@ class Pathod(tcp.TCPServer):
|
|||
self.staticdir = staticdir
|
||||
self.prefix = prefix
|
||||
self.sizelimit = sizelimit
|
||||
self.noweb, self.nocraft, self.noapi = noweb, nocraft, noapi
|
||||
if not noapi:
|
||||
app.api()
|
||||
self.app = app.app
|
||||
self.noweb = noweb
|
||||
self.nocraft = nocraft
|
||||
self.app.config["pathod"] = self
|
||||
self.log = []
|
||||
self.logid = 0
|
||||
|
|
9
pathod
9
pathod
|
@ -26,9 +26,13 @@ if __name__ == "__main__":
|
|||
"--limit-size", dest='sizelimit', default=None, type=str,
|
||||
help='Size limit of served responses. Understands size suffixes, i.e. 100k.'
|
||||
)
|
||||
parser.add_argument(
|
||||
"--noapi", dest='noapi', default=False, action="store_true",
|
||||
help='Disable API.'
|
||||
)
|
||||
parser.add_argument(
|
||||
"--noweb", dest='noweb', default=False, action="store_true",
|
||||
help='Disable web interface and API.'
|
||||
help='Disable both web interface and API.'
|
||||
)
|
||||
parser.add_argument(
|
||||
"--nocraft", dest='nocraft', default=False, action="store_true",
|
||||
|
@ -90,7 +94,8 @@ if __name__ == "__main__":
|
|||
anchors = alst,
|
||||
sizelimit = sizelimit,
|
||||
noweb = args.noweb,
|
||||
nocraft = args.nocraft
|
||||
nocraft = args.nocraft,
|
||||
noapi = args.noapi
|
||||
)
|
||||
except pathod.PathodError, v:
|
||||
parser.error(str(v))
|
||||
|
|
Loading…
Reference in New Issue