-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapi.py
More file actions
33 lines (22 loc) · 794 Bytes
/
Copy pathapi.py
File metadata and controls
33 lines (22 loc) · 794 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
32
33
from flask import Flask, request, jsonify
from solver import Solver
print("Starting API")
app = Flask(__name__)
user_agent = "Mozilla/5.0 (X11; Linux x86_64; rv:125.0) Gecko/20100101 Firefox/125.0"
solver = Solver(user_agent)
solver.prepare()
@app.route('/solve-captcha', methods=['POST'])
def solve_captcha():
solver.clear_cache()
print("Solving captcha")
data = request.get_json()
url_captcha = data.get('url')
if not url_captcha:
return jsonify({'error': 'URL is required'}), 400
session_token = solver.solve(url_captcha)
if session_token:
return jsonify({'session_token': session_token}), 200
else:
return jsonify({'error': 'Failed to solve captcha'}), 500
if __name__ == '__main__':
app.run(host="0.0.0.0", port=5000)