Skip to content

Instantly share code, notes, and snippets.

Created Feb 5, 2016
What would you like to do?
<!DOCTYPE html>
<meta charset="utf-8">
<p>{% if form.url.errors %}
{{ form.url.errors|join(' ') }}
{% endif %}
your input url
<a href="{{ url }}" target="_blank">{{ url }}</a>
<form method="post">
<input type="text" name="url" style="width:300px;" />
<input type="submit" value="Submit"/>
#(๑¯ω¯๑) coding:utf8 (๑¯ω¯๑)
import os
import flask
from flask import Flask
from wtforms.form import Form
from wtforms.validators import DataRequired, URL
from wtforms import StringField
app = Flask(__name__)
class UrlForm(Form):
url = StringField("Link", validators=[DataRequired(), URL()])
@app.route('/', methods=['GET', 'POST'])
def show_data():
form = UrlForm(flask.request.form)
if flask.request.method == "POST" and form.validate():
url =
url = flask.request.url
return flask.render_template('form.html', url=url, form=form)
if __name__ == '__main__':
app.debug = True'IP', ''), int(os.getenv('PORT', 8080)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment