-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAPIhost.py
More file actions
24 lines (19 loc) · 839 Bytes
/
APIhost.py
File metadata and controls
24 lines (19 loc) · 839 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
import json
import propertySearch as ps
import random
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
app = FastAPI()
app.add_middleware(
CORSMiddleware,
allow_origins=["http://localhost:4200"], # Angular app URL
allow_credentials=True,
allow_methods=["*"], # Allows all HTTP methods (GET, POST, etc.)
allow_headers=["*"], # Allows all headers
)
@app.get("/getProperties")
def get_properties(location: str, limit: int, minPrice: int, maxPrice: int, listingType: str):
return {"properties": ps.propSearch(location, limit, minPrice, maxPrice, listingType)}
@app.get("/getRent")
def get_rent(address: str, apiKey: str, propertyType: str, bedrooms: str, bathrooms: str, squareFootage: str):
return ps.calcRent(address, apiKey, propertyType, bedrooms, bathrooms, squareFootage)