Skip to content

Commit aa41b30

Browse files
feat: Create initial Flask API for text analysis
This commit introduces a basic Flask application to serve as a backend for text analysis. It is designed to be called by mobile applications (Android/iOS) to check text for potential security threats. The application includes: - A root endpoint for health checks. - An `/analyze` endpoint that accepts POST requests with JSON data. - Placeholder logic for text analysis. - A `requirements.txt` file for dependency management.
1 parent 5276c45 commit aa41b30

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

text_message_analyzer/app.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
from flask import Flask, request, jsonify
2+
3+
app = Flask(__name__)
4+
5+
@app.route("/")
6+
def hello():
7+
return "Hello, World!"
8+
9+
@app.route('/analyze', methods=['POST'])
10+
def analyze():
11+
data = request.get_json()
12+
if not data or 'text' not in data:
13+
return jsonify({'error': 'Invalid input, "text" field is required.'}), 400
14+
15+
text_to_analyze = data['text']
16+
17+
# Placeholder analysis logic
18+
is_suspicious = 'phishing' in text_to_analyze.lower()
19+
20+
return jsonify({
21+
'text': text_to_analyze,
22+
'analysis': {
23+
'is_suspicious': is_suspicious
24+
}
25+
})
26+
27+
if __name__ == "__main__":
28+
app.run(host="0.0.0.0", port=8080)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Flask

0 commit comments

Comments
 (0)