Skip to content

Instantly share code, notes, and snippets.

@daleysoftware
Last active October 28, 2015 03:38
Show Gist options
  • Save daleysoftware/115b03f236b2e1efd079 to your computer and use it in GitHub Desktop.
Save daleysoftware/115b03f236b2e1efd079 to your computer and use it in GitHub Desktop.
Simple flask app that takes input HTML and removes all the span tags.
<!doctype html>
<form>
HTML with span tags:
<br><br>
<input type="text" name="html">
<br><br>
<input type="submit" value="Remove ALL the spans!">
</form>
{% if html %}
<p>{{ html }}</p>
{% endif %}
from flask import Flask, render_template, request
import bs4
app = Flask(__name__)
app.debug = True
@app.route('/', methods=['GET'])
def index():
html = request.args.get('html')
print(html)
if html is not None:
soup = bs4.BeautifulSoup(html, 'html.parser')
for match in soup.findAll('span'):
match.unwrap()
html = soup
return render_template('index.html', html=html)
if __name__ == '__main__':
app.run(
host="0.0.0.0",
port=int("5555")
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment