This is a FastAPI application to scrape and serve town scores from ville-ideale.fr.
- Python 3.10 or higher
- (Optional) An ngrok account if you want to make your API accessible from the internet
-
Clone the repository
git clone https://github.com/your-username/ville-ideale-api.git cd ville-ideale-api
-
Create a virtual environment (recommended)
python -m venv venv venv\Scripts\activate # On Windows
-
Install the dependencies
pip install -r requirements.txt
-
Without ngrok:
python main.py
Access the API at
http://127.0.0.1:8000
-
With ngrok (Optional):
- Set the
NGROK_AUTH_TOKEN
environment variable.- In PowerShell:
$env:NGROK_AUTH_TOKEN="your_token_here"
- In Command Prompt:
set NGROK_AUTH_TOKEN="your_token_here"
- In PowerShell:
- Run the API:
python main.py
The public URL will be printed.
- Set the
The API has two endpoints:
/
: Welcome message and usage information./score/{town_name}_{cog_code}
: Get the score of a specific town. For example:GET /score/antony_92002
- The scraper respects rate limits.
- The scraper caches results for one hour.
ngrok
can be used to create a public URL to test the API remotely.