-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrd
138 lines (94 loc) · 5.74 KB
/
rd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
# WebApp boilerplate with React JS and Flask API
Build web applications using React.js for the front end and python/flask for your backend API.
- Documentation can be found here: https://start.4geeksacademy.com/starters/react-flask
- Here is a video on [how to use this template](https://www.loom.com/share/f37c6838b3f1496c95111e515e83dd9b)
- Integrated with Pipenv for package managing.
- Fast deployment to heroku [in just a few steps here](https://start.4geeksacademy.com/backend/deploy-heroku-posgres).
- Use of .env file.
- SQLAlchemy integration for database abstraction.
### 1) Installation:
> If you use Github Codespaces (recommended) or Gitpod this template will already come with Python, Node and the Posgres Database installed. If you are working locally make sure to install Python 3.10, Node
It is recomended to install the backend first, make sure you have Python 3.8, Pipenv and a database engine (Posgress recomended)
1. Install the python packages: `$ pipenv install`
2. Create a .env file based on the .env.example: `$ cp .env.example .env`
---- Auto Agenda Taller ----
pipenv install flask-jwt-extended
pipenv install Flask-Bcrypt
npm install use-count-up --legacy-peer-deps
sudo apt-get update
sudo apt-get install postgresql-client
sudo apt-get install postgresql
sudo service postgresql start
sudo service postgresql status
# Conectarse a PostgreSQL como el usuario `postgres`
psql -U postgres
# Crear el usuario `gitpod` con una contraseña
CREATE USER gitpod WITH PASSWORD 'postgres';
# Otorgar privilegios para que `gitpod` pueda crear bases de datos
ALTER USER gitpod WITH CREATEDB;
# Crear la base de datos `auto_agenda_taller_db` y asignar el propietario `gitpod`
CREATE DATABASE auto_agenda_taller_db OWNER gitpod;
# Otorgar todos los privilegios sobre la base de datos `auto_agenda_taller_db` al usuario `gitpod`
GRANT ALL PRIVILEGES ON DATABASE auto_agenda_taller_db TO gitpod;
# Salir de `psql`
\q
# Eliminar migraciones antiguas y crear nuevas migraciones
rm -R -f ./migrations &&
pipenv run init
# Eliminar la base de datos `auto_agenda_taller_db` (si existe) y crearla de nuevo
dropdb -h localhost -U gitpod auto_agenda_taller_db || true &&
createdb -h localhost -U gitpod auto_agenda_taller_db || true
# Contraseña: postgres
# Agregar la extensión `unaccent` a la base de datos
psql -h localhost -U gitpod -d auto_agenda_taller_db -c 'CREATE EXTENSION unaccent;' || true
# Contraseña: postgres
# Realizar las migraciones y aplicar las actualizaciones a la base de datos
pipenv run migrate &&
pipenv run upgrade
# Probar la conexión a la base de datos
psql -h localhost -U gitpod -d auto_agenda_taller_db -W
npm install bootstrap
npm install antd
npm install moment
-----------------------------
3. Install your database engine and create your database, depending on your database you have to create a DATABASE_URL variable with one of the possible values, make sure you replace the valudes with your database information:
| Engine | DATABASE_URL |
| --------- | --------------------------------------------------- |
| SQLite | sqlite:////test.db |
| MySQL | mysql://username:password@localhost:port/example |
| Postgress | postgres://username:password@localhost:5432/example |
4. Migrate the migrations: `$ pipenv run migrate` (skip if you have not made changes to the models on the `./src/api/models.py`)
5. Run the migrations: `$ pipenv run upgrade`
6. Run the application: `$ pipenv run start`
> Note: Codespaces users can connect to psql by typing: `psql -h localhost -U gitpod example`
### Undo a migration
You are also able to undo a migration by running
```sh
$ pipenv run downgrade
```
### Backend Populate Table Users
To insert test users in the database execute the following command:
```sh
$ flask insert-test-users 5
```
And you will see the following message:
```
Creating test users
[email protected] created.
[email protected] created.
[email protected] created.
[email protected] created.
[email protected] created.
Users created successfully!
```
### **Important note for the database and the data inside it**
Every Github codespace environment will have **its own database**, so if you're working with more people eveyone will have a different database and different records inside it. This data **will be lost**, so don't spend too much time manually creating records for testing, instead, you can automate adding records to your database by editing ```commands.py``` file inside ```/src/api``` folder. Edit line 32 function ```insert_test_data``` to insert the data according to your model (use the function ```insert_test_users``` above as an example). Then, all you need to do is run ```pipenv run insert-test-data```.
### Front-End Manual Installation:
- Make sure you are using node version 14+ and that you have already successfully installed and runned the backend.
1. Install the packages: `$ npm install`
2. Start coding! start the webpack dev server `$ npm run start`
## Publish your website!
This boilerplate it's 100% read to deploy with Render.com and Heroku in a matter of minutes. Please read the [official documentation about it](https://start.4geeksacademy.com/deploy).
### Contributors
This template was built as part of the 4Geeks Academy [Coding Bootcamp](https://4geeksacademy.com/us/coding-bootcamp) by [Alejandro Sanchez](https://twitter.com/alesanchezr) and many other contributors. Find out more about our [Full Stack Developer Course](https://4geeksacademy.com/us/coding-bootcamps/part-time-full-stack-developer), and [Data Science Bootcamp](https://4geeksacademy.com/us/coding-bootcamps/datascience-machine-learning).
You can find other templates and resources like this at the [school github page](https://github.com/4geeksacademy/).