Make `preflight` request pass okay
[asis23-votoe-server.git] / README.md
blob4abf6d448a0622484b42372d084164606bf29770
1 VOTAR REST API
2 --------------
4 ```
5 POST   /candidates {"name":string} -> {"id":number,"name":string}
6 DELETE /candidates/id
7 GET    /candidates -> [{"id":number,"name":string}]
8 DELETE /candidates
9 POST   /vote {"id":number}
10 GET    /report -> [{"id":number,"name":string,"votes":number}]
11 ```
13 --------------------------------------------------------------------------------
15 SQLite
16 ------
18 Primero hay que [instalar sqlite](https://codigofacilito.com/articulos/configurando-sqlite).
20 En mi caso ([termux](https://termux.dev/en/)), el comando para instalar SQLite es:
22 ```
23 $ pkg install sqlite
24 ```
26 Controlar que SQLite esté [habilitado en PHP](https://www.php.net/manual/es/sqlite3.installation.php).
28 ```
29 $ php -i | grep -i 'sqlite' | grep -i 'ena'
30 PDO Driver for SQLite 3.x => enabled
31 SQLite3 support => enabled
32 ```
34 Crear la base de datos con el siguiente comando:
36 ```
37 $ sqlite3 database.sqlite < votar.sql
38 ```
40 En la siguiente página se puede aprender un poco más sobre SQLite: [SQLite PHP](https://desarrolloweb.com/articulos/sqlite-php).
42 --------------------------------------------------------------------------------
44 Container Image
45 ---------------
47 Build (docker/container) image
49 ```bash
50 docker build --rm \
51     --tag 'edi2/server' \
52     .
53 ```
55 Run PHP server
57 ```bash
58 docker run --tty --interactive --rm \
59     --name edi2-server \
60     --publish 8080:80 \
61     edi2/server
62 ```