Ejemplo n.º 1
0
def addnew():
    if request.method == "POST":
        if u'website' in request.form:
            website = request.form['website']
            try:
                font = Font.objects.get(site_url=website)
            except db.DoesNotExist:
                font = Font(site_url=website)
                font.name = get_all_fonts(font.site_url)
                q = urlparse.urlparse(font.site_url)
                font.save()
        return redirect(url_for('view_site', website=q.hostname), 302)
    return render_template('addnew.html')
Ejemplo n.º 2
0
def addnew():
    if request.method == "POST":
        if u'website' in request.form:
            website = request.form['website']
            try:
                font = Font.objects.get(site_url=website)
            except db.DoesNotExist:
                font = Font(site_url=website)
                font.name = get_all_fonts(font.site_url)
                q = urlparse.urlparse(font.site_url)
                font.save()
        return redirect(url_for('view_site', website=q.hostname), 302)
    return render_template('addnew.html')
Ejemplo n.º 3
0
def add_url_file(filename):
	try:
		for url in yield_url(filename):
			url = url.strip("\n")
			try:
				Font.objects.get(site_url=url)
			except db.DoesNotExist:
				font = Font(site_url=url)
				font.save()
				# TODO: Use logging library rather than print
				print("{0} url added.".format(url))
	except (IOError, mongoengine.errors.ValidationError) as e:
		print(e)
Ejemplo n.º 4
0
def add_url_file(filename):
    try:
        for url in yield_url(filename):
            url = url.strip("\n")
            try:
                Font.objects.get(site_url=url)
                print("{0} already exists.".format(url))
            except db.DoesNotExist:
                font = Font(site_url=url)
                font.save()
                # TODO: Use logging library rather than print
                print("{0} url added.".format(url))
    except (IOError, mongoengine.errors.ValidationError) as e:
        print(e)