-
Notifications
You must be signed in to change notification settings - Fork 4
/
forms.py
25 lines (20 loc) · 876 Bytes
/
forms.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# -*- coding: utf-8 -*-
from flask_wtf import FlaskForm
from wtforms import StringField, SubmitField
from wtforms.validators import DataRequired, Regexp
import re
class URL(Regexp):
def __init__(self, require_tld=True, message=None):
tld_part = (require_tld and r'\.[a-z]{2,10}' or '')
regex = r'([^/:]+%s|([0-9]{1,3}\.){3}[0-9]{1,3})(:[0-9]+)?$' % tld_part
super(URL, self).__init__(regex, re.IGNORECASE, message)
def __call__(self, form, field):
if self.message is None:
self.message = field.gettext('Invalid Domain Name (e.g. google.com)')
super(URL, self).__call__(form, field)
class LoginForm(FlaskForm):
domain = StringField('Domain Name (e.g. google.com)', validators=[URL()])
submit = SubmitField('Classify')
virustotal = SubmitField('VirusTotal')
prediction = 'legit'
whois = False