RockCoder23 commited on
Commit
fd71b23
·
verified ·
1 Parent(s): bb514b5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -4
app.py CHANGED
@@ -1,15 +1,19 @@
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({
@@ -19,5 +23,5 @@ def fetch_url_content():
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)
 
 
1
  from flask import Flask, request, jsonify
2
+ import requests
3
 
4
  app = Flask(__name__)
5
 
6
+ @app.route('/')
7
+ def home():
8
+ return "Welcome to the Flask URL Fetcher!"
9
+
10
  @app.route('/fetch', methods=['POST'])
11
  def fetch_url_content():
12
  data = request.json
13
  target_url = data.get('url')
14
  if not target_url:
15
  return jsonify({"error": "No URL provided"}), 400
16
+
17
  try:
18
  response = requests.get(target_url)
19
  return jsonify({
 
23
  except Exception as e:
24
  return jsonify({"error": str(e)}), 500
25
 
26
+ if __name__ == "__main__":
27
+ app.run(host='0.0.0.0', port=7860)