up stuff
This commit is contained in:
parent
656c3fd414
commit
1c17b57d8a
37 changed files with 2818 additions and 469 deletions
136
README.md
Normal file
136
README.md
Normal file
|
@ -0,0 +1,136 @@
|
|||
# OpenEventDatabase Backend
|
||||
|
||||
OpenEventDatabase (OEDB) is a database for events with geographic information.
|
||||
It is a collaborative way to share things that have no space in OpenStreetMap.
|
||||
|
||||
## Getting Started
|
||||
|
||||
### Prerequisites
|
||||
|
||||
- Docker and Docker Compose
|
||||
- PostgreSQL (if running locally without Docker)
|
||||
- Python 3.x (if running locally without Docker)
|
||||
|
||||
### Installation
|
||||
Copiez le fichier d'environnement pour accéder à la base de données.
|
||||
```shell
|
||||
cp .env.example .env
|
||||
```
|
||||
installez la base de données.
|
||||
|
||||
```shell
|
||||
py -m venv venv
|
||||
source venv/bin/activate
|
||||
pip install -r requirements.txt
|
||||
bash setup_db.sh
|
||||
```
|
||||
vous pouvez ajouter des données d'exemple:
|
||||
|
||||
```shell
|
||||
cd data
|
||||
py import_example_from_csv.co2db.py
|
||||
```
|
||||
|
||||
|
||||
#### Using Docker (Recommended)
|
||||
|
||||
1. Clone the repository:
|
||||
```
|
||||
git clone https://github.com/yourusername/openeventdatabase.git
|
||||
cd openeventdatabase/backend
|
||||
```
|
||||
|
||||
2. Start the services using Docker Compose:
|
||||
```
|
||||
docker-compose up -d
|
||||
```
|
||||
|
||||
This will start both the PostgreSQL database and the backend API server.
|
||||
|
||||
3. Access the API at `http://localhost:8080`
|
||||
|
||||
#### Running Locally
|
||||
|
||||
1. Install dependencies:
|
||||
```
|
||||
pip install -r requirements.txt
|
||||
```
|
||||
|
||||
2. Set up the database:
|
||||
```
|
||||
./setup_db.sh
|
||||
```
|
||||
|
||||
3. Verify database tables are properly created:
|
||||
```
|
||||
./check_tables.sh
|
||||
```
|
||||
|
||||
4. Start the server with uwsgi:
|
||||
```
|
||||
uwsgi --http :8080 --wsgi-file backend.py --callable app
|
||||
```
|
||||
|
||||
Or with gunicorn:
|
||||
```
|
||||
gunicorn backend:app
|
||||
```
|
||||
|
||||
Note: The server will automatically check database connectivity at startup and will exit if the PostgreSQL database is not responding.
|
||||
|
||||
If you encounter permission errors when accessing the API (such as "permission denied for table events"), run the setup script again to ensure proper permissions:
|
||||
```
|
||||
./setup_db.sh
|
||||
```
|
||||
|
||||
You can also test database permissions with:
|
||||
```
|
||||
./test_permissions.sh
|
||||
```
|
||||
|
||||
Or specifically test permissions on the events table:
|
||||
```
|
||||
./test_table_permissions.sh
|
||||
```
|
||||
|
||||
### Environment Variables
|
||||
|
||||
- `DB_NAME`: Database name (default: "oedb")
|
||||
- `DB_HOST`: Database host (default: localhost)
|
||||
- `DB_USER`: Database user (default: postgres)
|
||||
- `POSTGRES_PASSWORD`: Database password
|
||||
- `NEW_USER`: New PostgreSQL user to create with full permissions (default: "oedb_user")
|
||||
- `NEW_PASSWORD`: Password for the new PostgreSQL user (default: "oedb_password")
|
||||
|
||||
### Mock Data
|
||||
|
||||
The repository includes scripts to create and check mock events in the database:
|
||||
|
||||
1. Create mock events:
|
||||
```
|
||||
./create_mock_events.py
|
||||
```
|
||||
This script creates 18 mock events (3 for each category: traffic, nature, weather, sport, conference, party) with start dates slightly before the current date and end dates far in the future.
|
||||
|
||||
2. Check mock events:
|
||||
```
|
||||
./check_mock_events.py
|
||||
```
|
||||
This script checks the mock events in the database, showing counts by category and date ranges for each event.
|
||||
|
||||
### API Documentation
|
||||
|
||||
The OpenEventDatabase API allows you to search for events using various query parameters. You can filter events by:
|
||||
|
||||
- Event type or category (`what`)
|
||||
- Time period (`when`, `start`, `stop`)
|
||||
- Geographic location (`bbox`, `near`, `polyline`)
|
||||
- And more...
|
||||
|
||||
For detailed information about the available query parameters, examples, and response format, see the [API Query Parameters Documentation](API_QUERY_PARAMS.md).
|
||||
Have a look at the swagger file.
|
||||
`swagger.json`
|
||||
|
||||
## License
|
||||
|
||||
See the LICENSE file for details.
|
Loading…
Add table
Add a link
Reference in a new issue