-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
29 lines (23 loc) · 986 Bytes
/
main.py
File metadata and controls
29 lines (23 loc) · 986 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
from fastapi import FastAPI
app = FastAPI(
title="Scraper API",
description="Un semplice server FastAPI per le funzione di scraping",
version="1.0.0"
)
def funzione_1():
"""Scrivere qui la Funzione di scraping implementata. Ho inserito qui una semplice di esempio"""
return 2*2
def get_hello_message():
"""Benvenuti nello swagger che espone le API per il servizio di scraping"""
return {"message": "Ciao!"}
@app.get("/", summary="Homepage", description="Rotta principale di benvenuto")
def hello_world():
"""Rotta API che richiama la funzione hello world"""
return get_hello_message()
@app.get("/funzione_1", summary="Funzione 1", description="Esegue un calcolo semplice")
def prova_rotte_esempio():
"""Chiamare qui la funzione definita sopra. Se sono poche, va bene inserirle tutte nel main."""
return {"output della funzione": funzione_1()}
if __name__ == "__main__":
import uvicorn
uvicorn.run(app, host="0.0.0.0", port=8000)