Submit URL through a POST request instead of a GET. Encore URL when querying the cache

travis
Raphaël Vinot 2015-03-11 18:14:25 +01:00
parent a113b4178e
commit 52cefba027
4 changed files with 21 additions and 5 deletions

View File

@ -375,8 +375,10 @@ def whois(server, port, domain, ignorelist, replacelist):
if domain.startswith('http'):
fex = Faup()
fex.decode(domain)
domain = fex.get_domain().lower()
s.send(domain + "\r\n")
d = fex.get_domain().lower()
else:
d = domain
s.send(d + "\r\n")
response = ''
while True:
d = s.recv(4096)

View File

@ -1,5 +1,6 @@
import json
import os
from base64 import urlsafe_b64decode
from flask import Flask, render_template, request, Response, redirect, url_for, flash
from flask_mail import Mail, Message
@ -273,6 +274,7 @@ def create_app(configfile=None):
@app.route('/get_cache/<path:url>')
def get_cache(url):
url = urlsafe_b64decode(url.encode('utf-8'))
data = get_cached(url)
dumped = json.dumps(data, sort_keys=True, indent=4, separators=(',', ': '))
return dumped
@ -290,8 +292,10 @@ def create_app(configfile=None):
msg.body = json.dumps(data, sort_keys=True, indent=4, separators=(',', ': '))
mail.send(msg)
@app.route('/submit/<path:url>')
def send_mail(url):
@app.route('/submit', methods=['POST'])
def send_mail():
data = json.loads(request.data)
url = data["url"]
if get_mail_sent(url):
flash('Mail already sent to CIRCL.')
else:

View File

@ -66,6 +66,15 @@
$scope.query('start', {"url": userInput}, check_validity);
};
$scope.submit_email = function() {
$scope.query('submit', {"url": $scope.query_url}, function(){
$scope.query_url = '';
$scope.urls = '';
$scope.input_url = '';
});
};
});
app.directive('uqUrlreport', function(globFct) {

View File

@ -57,7 +57,8 @@
</div>
<div ng-show="urls">
<br/>
<center><a href="submit/{{ query_url }}">Send report to CIRCL</a></center>
<center><a ng-click="submit_email()">Send report to CIRCL</a></center>
<!-- <center><a href="submit/{{ query_url }}">Send report to CIRCL</a></center> -->
<br/>
</div>
<div ng-repeat="url in urls">