Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from fastapi import FastAPI
|
2 |
+
import requests
|
3 |
+
|
4 |
+
app = FastAPI()
|
5 |
+
|
6 |
+
@app.get("/fetch")
|
7 |
+
def fetch_html(url: str):
|
8 |
+
try:
|
9 |
+
headers = {"User-Agent": "Mozilla/5.0"}
|
10 |
+
response = requests.get(url, headers=headers)
|
11 |
+
response.raise_for_status()
|
12 |
+
return {"html": response.text}
|
13 |
+
except requests.RequestException as e:
|
14 |
+
return {"error": str(e)}
|