RockCoder23 commited on
Commit
083ada9
·
verified ·
1 Parent(s): 2743da2

Update get.py

Browse files
Files changed (1) hide show
  1. get.py +23 -0
get.py CHANGED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import requests
2
+ from flask import Flask, request, jsonify
3
+
4
+ app = Flask(__name__)
5
+
6
+ @app.route('/fetch', methods=['POST'])
7
+ def fetch_url_content():
8
+ data = request.json
9
+ target_url = data.get('url')
10
+ if not target_url:
11
+ return jsonify({"error": "No URL provided"}), 400
12
+
13
+ try:
14
+ response = requests.get(target_url)
15
+ return jsonify({
16
+ "status_code": response.status_code,
17
+ "content": response.text
18
+ })
19
+ except Exception as e:
20
+ return jsonify({"error": str(e)}), 500
21
+
22
+ if __name__ == '__main__':
23
+ app.run(host='0.0.0.0', port=7860)