Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from urllib2 import Request, urlopen, URLError
- from flask import Flask, render_template, request, redirect
- def is_valid_url(url):
- req = Request(url, headers={'User-Agent' : "Magic Browser"})
- try:
- response = urlopen(req)
- except URLError, e:
- return False
- else:
- return True
- errors = []
- word = 'linkedin.com'
- if is_valid_url(word):
- print 'valid url'
- else:
- errors.append("- Something's fishy with that URL")
- @app.route('/')
- def hello_world():
- author = "Gil"
- return render_template('index.html', author=author)
- @app.route('/textcheck', methods = ['POST'])
- def signup():
- all_good = False
- message = request.form['text']
- print len(message)
- errors, all_good = split_them(message)
- if errors == []:
- all_good = True
- return render_template('text-result1.html', errors=errors, text=message, all_good=all_good)
- @app.route('/text-result1.html')
- def tweets():
- return render_template('text-result1.html', errors=errors, text=message, all_good=all_good)
- if __name__ == '__main__':
- app.run()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement