-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwserver.py
More file actions
31 lines (23 loc) · 834 Bytes
/
wserver.py
File metadata and controls
31 lines (23 loc) · 834 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
from flask import Flask, render_template, request, jsonify
from flask_cors import CORS # Import CORS from flask_cors
import pywhatkit
from datetime import datetime
app = Flask(__name__)
CORS(app) #
@app.route('/')
def index():
return render_template('windex.html')
@app.route('/send_wishes', methods=['POST'])
def send_wishes():
data = request.json
# Extract form data
message = data.get('message')
contact = data.get('contact')
datetime_str = data.get('datetime')
# Parse datetime string
datetime_obj = datetime.fromisoformat(datetime_str)
# Send birthday wishes
pywhatkit.sendwhatmsg(contact, message, datetime_obj.hour, datetime_obj.minute)
return jsonify({'status': 'success'})
if __name__ == '__main__':
app.run(debug=True)