|
from flask import Flask, request, jsonify |
|
import requests |
|
import urllib3 |
|
from filelock import FileLock |
|
|
|
urllib3.disable_warnings() |
|
|
|
app = Flask(__name__) |
|
|
|
def verify_register(url): |
|
json_data = { |
|
'name': 'jack', |
|
'email': 'zdsdhddfjb@gamil.com', |
|
'password': 'zxc1234d', |
|
'confirm_password': 'zxc1234d', |
|
} |
|
|
|
try: |
|
response = requests.post(f'{url}/api/auth/register', json=json_data, verify=False, timeout=15) |
|
if response.status_code != 200: |
|
return False, url |
|
return True, url |
|
|
|
except requests.exceptions.RequestException: |
|
print(f'{url} 请求失败') |
|
return False, url |
|
|
|
@app.route('/', methods=['POST']) |
|
def register(): |
|
req_data = request.get_json() |
|
url = req_data.get('url') |
|
success, url = verify_register(url) |
|
if success: |
|
return jsonify({'message': '注册成功', 'url': url}), 200 |
|
else: |
|
return jsonify({'message': '注册失败或URL无法访问', 'url': url}), 400 |
|
|
|
if __name__ == '__main__': |
|
app.run(host='0.0.0.0', port=8080, debug=True) |
|
|