Spaces:
Sleeping
Sleeping
| import requests | |
| import json | |
| def test_prediction(): | |
| url = "http://localhost:8000/predict" | |
| payload = { | |
| "City": "Casablanca", | |
| "Neighborhood": "Anfa", | |
| "Type": "Appartement", | |
| "Surface": 100.0, | |
| "Rooms": 3, | |
| "Bedrooms": 2, | |
| "Standing": "Haut Standing", | |
| "Residency": "Public / Quartier ouvert", | |
| "Orientation": "Sud (Ensoleillé)", | |
| "View": "Sans vis-à-vis", | |
| "Condition": "Bon état", | |
| "Floor": 2, | |
| "Lift": 1, | |
| "Pool": 0, | |
| "Garden": 0, | |
| "Parking_Spots": 1, | |
| "Proximity_Tram": 1, | |
| "Proximity_University": 0, | |
| "Proximity_Mosque": 0 | |
| } | |
| # Actually, matching the Pydantic model in main.py | |
| payload = { | |
| "City": "Casablanca", | |
| "Neighborhood": "Anfa", | |
| "Type": "Appartement", | |
| "Surface": 100.0, | |
| "Rooms": 3, | |
| "Bedrooms": 2, | |
| "Standing": "Haut Standing", | |
| "Residency": "Public / Quartier ouvert", | |
| "Orientation": "Sud (Ensoleillé)", | |
| "View": "Sans vis-à-vis", | |
| "Condition": "Bon état", | |
| "Floor": 2, | |
| "Lift": 1, | |
| "Pool": 0, | |
| "Garden": 0, | |
| "Parking_Spots": 1, | |
| "Proximity_Tram": 1, | |
| "Proximity_University": 0, | |
| "Proximity_Mosque": 0 | |
| } | |
| try: | |
| response = requests.post(url, json=payload) | |
| print(f"Status: {response.status_code}") | |
| print(f"Response: {json.dumps(response.json(), indent=2, ensure_ascii=False)}") | |
| except Exception as e: | |
| print(f"Connection error: {e}") | |
| if __name__ == "__main__": | |
| test_prediction() | |