mirror of
https://github.com/simon987/od-database.git
synced 2025-04-19 18:36:44 +00:00
Updated README and catpchas are now toggled from the config
This commit is contained in:
parent
123f38e65d
commit
1b743e7aba
11
README.md
11
README.md
@ -11,16 +11,27 @@ sudo pip3 install -r requirements.txt
|
|||||||
```
|
```
|
||||||
Create `/config.py` and fill out the parameters. Sample config:
|
Create `/config.py` and fill out the parameters. Sample config:
|
||||||
```python
|
```python
|
||||||
|
# Leave default values for no CAPTCHAs
|
||||||
|
CAPTCHA_LOGIN = False
|
||||||
|
CAPTCHA_SUBMIT = False
|
||||||
CAPTCHA_SITE_KEY = ""
|
CAPTCHA_SITE_KEY = ""
|
||||||
CAPTCHA_SECRET_KEY = ""
|
CAPTCHA_SECRET_KEY = ""
|
||||||
|
|
||||||
|
# Flask secret key for sessions
|
||||||
FLASK_SECRET = ""
|
FLASK_SECRET = ""
|
||||||
RESULTS_PER_PAGE = (25, 50, 100, 250, 500, 1000)
|
RESULTS_PER_PAGE = (25, 50, 100, 250, 500, 1000)
|
||||||
|
# Headers for http crawler
|
||||||
HEADERS = {}
|
HEADERS = {}
|
||||||
|
# Token for the crawl server, used by the server to communicate to the crawl server
|
||||||
CRAWL_SERVER_TOKEN = ""
|
CRAWL_SERVER_TOKEN = ""
|
||||||
CRAWL_SERVER_PORT = 5001
|
CRAWL_SERVER_PORT = 5001
|
||||||
|
# Number of crawler instances (one per task)
|
||||||
CRAWL_SERVER_PROCESSES = 3
|
CRAWL_SERVER_PROCESSES = 3
|
||||||
|
# Number of threads per crawler instance
|
||||||
CRAWL_SERVER_THREADS = 20
|
CRAWL_SERVER_THREADS = 20
|
||||||
|
# Allow ftp websites in /submit
|
||||||
SUBMIT_FTP = False
|
SUBMIT_FTP = False
|
||||||
|
# Allow http(s) websites in /submit
|
||||||
SUBMIT_HTTP = True
|
SUBMIT_HTTP = True
|
||||||
```
|
```
|
||||||
|
|
||||||
|
28
app.py
28
app.py
@ -13,9 +13,12 @@ from task import TaskDispatcher, Task, CrawlServer
|
|||||||
from search.search import ElasticSearchEngine
|
from search.search import ElasticSearchEngine
|
||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
|
if config.CAPTCHA_SUBMIT or config.CAPTCHA_LOGIN:
|
||||||
recaptcha = ReCaptcha(app=app,
|
recaptcha = ReCaptcha(app=app,
|
||||||
site_key=config.CAPTCHA_SITE_KEY,
|
site_key=config.CAPTCHA_SITE_KEY,
|
||||||
secret_key=config.CAPTCHA_SECRET_KEY)
|
secret_key=config.CAPTCHA_SECRET_KEY)
|
||||||
|
else:
|
||||||
|
recaptcha = None
|
||||||
app.secret_key = config.FLASK_SECRET
|
app.secret_key = config.FLASK_SECRET
|
||||||
db = Database("db.sqlite3")
|
db = Database("db.sqlite3")
|
||||||
cache = Cache(app, config={'CACHE_TYPE': 'simple'})
|
cache = Cache(app, config={'CACHE_TYPE': 'simple'})
|
||||||
@ -317,7 +320,7 @@ def home():
|
|||||||
@app.route("/submit")
|
@app.route("/submit")
|
||||||
def submit():
|
def submit():
|
||||||
queued_websites = taskDispatcher.get_queued_tasks()
|
queued_websites = taskDispatcher.get_queued_tasks()
|
||||||
return render_template("submit.html", queue=queued_websites, recaptcha=recaptcha)
|
return render_template("submit.html", queue=queued_websites, recaptcha=recaptcha, show_captcha=config.CAPTCHA_SUBMIT)
|
||||||
|
|
||||||
|
|
||||||
def try_enqueue(url):
|
def try_enqueue(url):
|
||||||
@ -356,7 +359,7 @@ def try_enqueue(url):
|
|||||||
|
|
||||||
@app.route("/enqueue", methods=["POST"])
|
@app.route("/enqueue", methods=["POST"])
|
||||||
def enqueue():
|
def enqueue():
|
||||||
# if recaptcha.verify():
|
if not config.CAPTCHA_SUBMIT or recaptcha.verify():
|
||||||
|
|
||||||
url = os.path.join(request.form.get("url"), "")
|
url = os.path.join(request.form.get("url"), "")
|
||||||
message, msg_type = try_enqueue(url)
|
message, msg_type = try_enqueue(url)
|
||||||
@ -364,15 +367,14 @@ def enqueue():
|
|||||||
|
|
||||||
return redirect("/submit")
|
return redirect("/submit")
|
||||||
|
|
||||||
|
else:
|
||||||
# else:
|
flash("<strong>Error:</strong> Invalid captcha please try again", "danger")
|
||||||
# flash("<strong>Error:</strong> Invalid captcha please try again", "danger")
|
return redirect("/submit")
|
||||||
# return redirect("/submit")
|
|
||||||
|
|
||||||
|
|
||||||
@app.route("/enqueue_bulk", methods=["POST"])
|
@app.route("/enqueue_bulk", methods=["POST"])
|
||||||
def enqueue_bulk():
|
def enqueue_bulk():
|
||||||
# if recaptcha.verify():
|
if not config.CAPTCHA_SUBMIT or recaptcha.verify():
|
||||||
|
|
||||||
urls = request.form.get("urls")
|
urls = request.form.get("urls")
|
||||||
if urls:
|
if urls:
|
||||||
@ -392,23 +394,21 @@ def enqueue_bulk():
|
|||||||
return redirect("/submit")
|
return redirect("/submit")
|
||||||
else:
|
else:
|
||||||
return abort(500)
|
return abort(500)
|
||||||
|
else:
|
||||||
|
flash("<strong>Error:</strong> Invalid captcha please try again", "danger")
|
||||||
# else:
|
return redirect("/submit")
|
||||||
# flash("<strong>Error:</strong> Invalid captcha please try again", "danger")
|
|
||||||
# return redirect("/submit")
|
|
||||||
|
|
||||||
|
|
||||||
@app.route("/admin")
|
@app.route("/admin")
|
||||||
def admin_login_form():
|
def admin_login_form():
|
||||||
if "username" in session:
|
if "username" in session:
|
||||||
return redirect("/dashboard")
|
return redirect("/dashboard")
|
||||||
return render_template("admin.html", recaptcha=recaptcha)
|
return render_template("admin.html", recaptcha=recaptcha, show_captcha=config.CAPTCHA_LOGIN)
|
||||||
|
|
||||||
|
|
||||||
@app.route("/login", methods=["POST"])
|
@app.route("/login", methods=["POST"])
|
||||||
def admin_login():
|
def admin_login():
|
||||||
if recaptcha.verify():
|
if not config.CAPTCHA_LOGIN or recaptcha.verify():
|
||||||
|
|
||||||
username = request.form.get("username")
|
username = request.form.get("username")
|
||||||
password = request.form.get("password")
|
password = request.form.get("password")
|
||||||
|
@ -15,7 +15,9 @@
|
|||||||
<input class="form-control" name="password" placeholder="Password" type="password">
|
<input class="form-control" name="password" placeholder="Password" type="password">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{% if show_captcha %}
|
||||||
{{ recaptcha.get_code()|safe }}
|
{{ recaptcha.get_code()|safe }}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
<input type="submit" value="Login">
|
<input type="submit" value="Login">
|
||||||
|
|
||||||
|
@ -25,9 +25,11 @@
|
|||||||
<input class="form-control" name="url" id="url" placeholder="URL">
|
<input class="form-control" name="url" id="url" placeholder="URL">
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
{% if show_captcha %}
|
||||||
<div class="col">
|
<div class="col">
|
||||||
{# {{ recaptcha.get_code()|safe }}#}
|
{{ recaptcha.get_code()|safe }}
|
||||||
</div>
|
</div>
|
||||||
|
{% endif %}
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<input class="btn btn-primary" type="submit" value="Submit" title="Submit open directory">
|
<input class="btn btn-primary" type="submit" value="Submit" title="Submit open directory">
|
||||||
</div>
|
</div>
|
||||||
@ -42,9 +44,11 @@
|
|||||||
<textarea class="form-control" name="urls" id="urls" rows="10" placeholder="One URL per line, max. 10"></textarea>
|
<textarea class="form-control" name="urls" id="urls" rows="10" placeholder="One URL per line, max. 10"></textarea>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
{% if show_captcha %}
|
||||||
<div class="col">
|
<div class="col">
|
||||||
{# {{ recaptcha.get_code()|safe }}#}
|
{{ recaptcha.get_code()|safe }}
|
||||||
</div>
|
</div>
|
||||||
|
{% endif %}
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<input class="btn btn-primary" type="submit" value="Submit" title="Submit open directories">
|
<input class="btn btn-primary" type="submit" value="Submit" title="Submit open directories">
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user