aboutsummaryrefslogtreecommitdiff
path: root/fhost.py
diff options
context:
space:
mode:
authorMartin Herkt <lachs0r@srsfckn.biz>2017-01-01 20:27:31 +0100
committerMartin Herkt <lachs0r@srsfckn.biz>2017-01-01 21:20:39 +0100
commit6bc76907119e0f3be748d4fcb8919ba9f6db903a (patch)
treea3d45cb3f8ed02091841c0edc21543471dad7e8c /fhost.py
parentdo not shorten our host URLs (diff)
downloadhex-zero-6bc76907119e0f3be748d4fcb8919ba9f6db903a.tar.gz
hex-zero-6bc76907119e0f3be748d4fcb8919ba9f6db903a.tar.bz2
hex-zero-6bc76907119e0f3be748d4fcb8919ba9f6db903a.zip
add BEACON dump with start index for urlte.am
fixes #1
Diffstat (limited to 'fhost.py')
-rwxr-xr-xfhost.py20
1 files changed, 19 insertions, 1 deletions
diff --git a/fhost.py b/fhost.py
index 48d2d9d..4874196 100755
--- a/fhost.py
+++ b/fhost.py
@@ -1,7 +1,7 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
-from flask import Flask, abort, escape, make_response, redirect, request, send_from_directory, url_for
+from flask import Flask, abort, escape, make_response, redirect, request, send_from_directory, url_for, Response
from flask_sqlalchemy import SQLAlchemy
from flask_script import Manager
from flask_migrate import Migrate, MigrateCommand
@@ -243,6 +243,24 @@ def get(path):
abort(404)
+@app.route("/dump_urls/")
+@app.route("/dump_urls/<int:start>")
+def dump_urls(start=0):
+ meta = "#FORMAT: BEACON\n#PREFIX: {}/\n\n".format(fhost_url("https"))
+
+ def gen():
+ yield meta
+
+ for url in URL.query.order_by(URL.id.asc()).offset(start):
+ if url.url.startswith("http") or url.url.startswith("https"):
+ bar = "|"
+ else:
+ bar = "||"
+
+ yield url.getname() + bar + url.url + "\n"
+
+ return Response(gen(), mimetype="text/plain")
+
@app.route("/", methods=["GET", "POST"])
def fhost():
if request.method == "POST":
bgstack15