Hello everyone, In this tutorial, we will show you how to develop the simple spell checker application using Flask, TextBlob and Bootstrap 4. The example program has been tested and shared in the post.
Flask Service Layer
from flask import Flask, render_template, request from textblob import TextBlob app = Flask(__name__) @app.route('/') def home(): return render_template('index.html') @app.route('/correct', methods=['POST']) def correct(): if request.method == 'POST': input = request.form['input'] text = TextBlob(input) return render_template('index.html', input=text, output=text.correct()) app.run()
Flask View Layer
<html> <head> <title>Spell Checker</title> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous"> </head> <body class="container"> <nav class="navbar navbar-expand-lg navbar-dark bg-dark"> <a class="navbar-brand" href="#">Spell Checker</a> </nav> <div class="row justify-content-center"> <div class="col-11"> <form action="/correct" method="post"> <div class="form-group"> <label for="input">Input</label> <textarea class="form-control" id="input" name="input" rows="5">{{ input }}</textarea> </div> <div class="form-group"> <button type="submit" class="btn btn-primary">Correct</button> <button type="reset" class="btn btn-danger">Clear</button> </div> <div class="form-group"> <label for="output">Output</label> <textarea class="form-control" id="output" name="output" rows="5">{{ output }}</textarea> </div> </form> </div> </div> </body> </html>
Output

References
More from my site

Hello, folks, I am a founder of idineshkrishnan.com. I love open source technologies, If you find my tutorials are useful, please consider making donations to these charities.
No responses yet