forked from DHBW-FN-TIT20/essensfindung
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
formatted and added response_classes (DHBW-FN-TIT20#31)
- Loading branch information
1 parent
610a15c
commit 926049d
Showing
3 changed files
with
45 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,34 @@ | ||
"""Router for the Home of the Website""" | ||
from datetime import datetime | ||
from schemes import scheme_filter, Cuisine, Allergies, scheme_rest | ||
|
||
import fastapi | ||
from fastapi.responses import HTMLResponse | ||
from starlette.requests import Request | ||
from starlette.templating import Jinja2Templates | ||
|
||
from schemes import Allergies | ||
from schemes import Cuisine | ||
from schemes import scheme_filter | ||
from schemes import scheme_rest | ||
|
||
templates = Jinja2Templates("templates") | ||
router = fastapi.APIRouter() | ||
|
||
|
||
@router.get("/") | ||
@router.get("/", response_class=HTMLResponse) | ||
def index(request: Request): | ||
"""Return the renderd template for the /index.html | ||
Args: | ||
request (Request): Requerd for Template | ||
""" | ||
#request filter of user | ||
rest_filter = scheme_filter.FilterRest(cuisine=Cuisine.ASIAN, allergies=Allergies.LACTOSE, rating=4, costs=2, radius=15000, location=scheme_rest.LocationBase(lat="47.7007", lng="9.562")) | ||
# request filter of user | ||
rest_filter = scheme_filter.FilterRest( | ||
cuisine=Cuisine.ASIAN, | ||
allergies=Allergies.LACTOSE, | ||
rating=4, | ||
costs=2, | ||
radius=15000, | ||
location=scheme_rest.LocationBase(lat="47.7007", lng="9.562"), | ||
) | ||
return templates.TemplateResponse("index.html", {"request": request, "rest_filter": rest_filter}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,30 @@ | ||
"""Router for the Home of the Website""" | ||
import enum | ||
from schemes import scheme_rest | ||
|
||
import fastapi | ||
from fastapi.responses import HTMLResponse | ||
from starlette.requests import Request | ||
from starlette.templating import Jinja2Templates | ||
|
||
from schemes import scheme_rest | ||
|
||
templates = Jinja2Templates("templates") | ||
router = fastapi.APIRouter() | ||
|
||
@router.get("/findrestaurant") | ||
async def findrestaurant(request: Request, rest_name: str, costs : float, cuisine : str): | ||
#api.Search_restaurant(...) | ||
restaurant = scheme_rest.Restaurant(place_id="PlaceID", name=rest_name, geometry=scheme_rest.Geometry(location=scheme_rest.LocationRest(lat="47.7007", lng="9.562", adr=cuisine)), | ||
maps_url="https://maps.google.com/?cid=10544281732087259755", rating=4.0, own_rating=costs, phone_number="07541", homepage="http://www.alpha-fn.de/") | ||
return templates.TemplateResponse("restaurant/restaurant_result.html", {"request": request, "restaurant": restaurant}) | ||
|
||
@router.get("/findrestaurant", response_class=HTMLResponse) | ||
async def findrestaurant(request: Request, rest_name: str, costs: float, cuisine: str): | ||
# api.Search_restaurant(...) | ||
restaurant = scheme_rest.Restaurant( | ||
place_id="PlaceID", | ||
name=rest_name, | ||
geometry=scheme_rest.Geometry(location=scheme_rest.LocationRest(lat="47.7007", lng="9.562", adr=cuisine)), | ||
maps_url="https://maps.google.com/?cid=10544281732087259755", | ||
rating=4.0, | ||
own_rating=costs, | ||
phone_number="07541", | ||
homepage="http://www.alpha-fn.de/", | ||
) | ||
return templates.TemplateResponse( | ||
"restaurant/restaurant_result.html", {"request": request, "restaurant": restaurant} | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters