Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,11 +1,20 @@
|
|
1 |
from fastapi import FastAPI
|
|
|
|
|
|
|
2 |
|
3 |
app = FastAPI(title="Deploying FastAPI Apps on Huggingface")
|
4 |
|
5 |
@app.get("/", tags=["Home"])
|
6 |
def api_home():
|
7 |
-
|
8 |
|
9 |
@app.post("/",tags=["hello"])
|
10 |
def hello(name: str):
|
11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
from fastapi import FastAPI
|
2 |
+
import requests
|
3 |
+
from bs4 import BeautifulSoup
|
4 |
+
import re
|
5 |
|
6 |
app = FastAPI(title="Deploying FastAPI Apps on Huggingface")
|
7 |
|
8 |
@app.get("/", tags=["Home"])
|
9 |
def api_home():
|
10 |
+
return {'detail': 'Welcome to FastAPI Tutorial!'}
|
11 |
|
12 |
@app.post("/",tags=["hello"])
|
13 |
def hello(name: str):
|
14 |
+
return {'message': f"hello {name}!"}
|
15 |
+
|
16 |
+
@app.get("/scrape", tags=["Scrape"])
|
17 |
+
def scrape(url: str):
|
18 |
+
response = requests.get(url)
|
19 |
+
soup = BeautifulSoup(response.text, "html.parser")
|
20 |
+
return soup.prettify()
|