Download Fg.py from Pezh/Login: direct link, hf CLI and curl.
- Browser
- Download file 796 Bytes
-
https://huggingface.co/spaces/Pezh/Login/resolve/main/Fg.py
- Command line
-
hf download hf://spaces/Pezh/Login/Fg.py
-
curl -L -o Fg.py https://huggingface.co/spaces/Pezh/Login/resolve/main/Fg.py
796 Bytes
| from flask import Flask, render_template, request, jsonify | |
| from difflib import SequenceMatcher | |
| app = Flask(__name__) | |
| list_1 = ['Item 1', 'Item 2', 'Item 3'] | |
| def index(): | |
| return render_template('index.html') | |
| def add_item(): | |
| item = request.json['item'] | |
| if item: | |
| list_1.append(item) | |
| return jsonify({'success': True, 'item': item}) | |
| return jsonify({'success': False}) | |
| def check_similarity(): | |
| input_text = request.json['item'] | |
| for item in list_1: | |
| if SequenceMatcher(None, input_text, item).ratio() > 0.5: | |
| return jsonify({'similar': True}) | |
| return jsonify({'similar': False}) | |
| if __name__ == '__main__': | |
| app.run(debug=True) |