Last active
October 28, 2015 03:38
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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 %} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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