|
| 1 | + |
| 2 | +<!-- Improved compatibility of back to top link: See: https://github.com/molro/backend/pull/73 --> |
| 3 | +<a name="readme-top"></a> |
| 4 | +<!-- |
| 5 | +*** Thanks for checking out the Best-README-Template. If you have a suggestion |
| 6 | +*** that would make this better, please fork the repo and create a pull request |
| 7 | +*** or simply open an issue with the tag "enhancement". |
| 8 | +*** Don't forget to give the project a star! |
| 9 | +*** Thanks again! Now go create something AMAZING! :D |
| 10 | +--> |
| 11 | + |
| 12 | + |
| 13 | + |
| 14 | +<!-- PROJECT SHIELDS --> |
| 15 | +<!-- |
| 16 | +*** I'm using markdown "reference style" links for readability. |
| 17 | +*** Reference links are enclosed in brackets [ ] instead of parentheses ( ). |
| 18 | +*** See the bottom of this document for the declaration of the reference variables |
| 19 | +*** for contributors-url, forks-url, etc. This is an optional, concise syntax you may use. |
| 20 | +*** https://www.markdownguide.org/basic-syntax/#reference-style-links |
| 21 | +--> |
| 22 | +<!-- PROJECT LOGO --> |
| 23 | +<br /> |
| 24 | +<div align="center"> |
| 25 | + |
| 26 | + <h3 align="center">FastAPI - Ejemplo de Uso con Entornos virtuales de Python</h3> |
| 27 | + |
| 28 | + <p align="center"> |
| 29 | + 🎯 Desarrollo de Python con entornos virtuales |
| 30 | + <br /> |
| 31 | + <a href="https://github.com/molro/backend"><strong>Archivos »</strong></a> |
| 32 | + <br /> |
| 33 | + <a href="https://github.com/molro/backend/issues">Reportar un bug</a> |
| 34 | + · |
| 35 | + <a href="https://github.com/molro/backend/issues">Asignar una feature</a> |
| 36 | + </p> |
| 37 | +</div> |
| 38 | + |
| 39 | + |
| 40 | + |
| 41 | +<!-- TABLE OF CONTENTS --> |
| 42 | +<!-- <details> |
| 43 | + <summary>Table of Contents</summary> |
| 44 | + <ol> |
| 45 | + <li> |
| 46 | + <a href="#about-the-project">About</a> |
| 47 | + <ul> |
| 48 | + <li><a href="#built-with">Built With</a></li> |
| 49 | + </ul> |
| 50 | + </li> |
| 51 | + <li> |
| 52 | + <a href="#getting-started">Getting Started</a> |
| 53 | + <ul> |
| 54 | + <li><a href="#prerequisites">Prerequisites</a></li> |
| 55 | + <li><a href="#installation">Installing </a></li> |
| 56 | + </ul> |
| 57 | + </li> |
| 58 | + <li><a href="#roadmap">Roadmap</a></li> |
| 59 | + <li><a href="#license">License</a></li> |
| 60 | + <li><a href="#contact">Contact</a></li> |
| 61 | + </ol> |
| 62 | +</details> --> |
| 63 | + |
| 64 | + |
| 65 | + |
| 66 | +<!-- ABOUT THE PROJECT --> |
| 67 | +## About |
| 68 | + |
| 69 | +Por defecto la instalación de Python, incluye una gran cantidad de librerías de manera nativa y por defecto en la instalación de Python. Sin embargo es habitual el uso de liberías de terceros, como en este caso FastAPI. |
| 70 | + |
| 71 | +Para instalar y manejar paquetes, el módulo pip es la herramienta que nos permite instalar estas librerías de terceros, sin embargo esto lo realiza de manera global. |
| 72 | + |
| 73 | +Cuando compartimos el código, mediante un repositorio en GitHub por ejemplo, para poder ejecutar la aplicación deberemos instalar todas aquellas librerías de terceros que hemos instalado previamente de manera manual, con el riesgo que eso conlleva. |
| 74 | + |
| 75 | +Para ello existen dos alternativas: |
| 76 | +* Usar contenedores (Docker por ejemplo) |
| 77 | +* Usar Entornos virtuales |
| 78 | + |
| 79 | +Porqué? |
| 80 | +* Tu tiempo es valioso y debes enfocarte en crear soluciones para resolver problemas que ayuden a otros. |
| 81 | +* No deberías pasar tiempo instalando y desinstalando versiones de Python una y otra vez por cada proyecto. |
| 82 | +* Deberías implementar el principio KISS para el resto de tu vida y esto es parte de ello :smile: |
| 83 | + |
| 84 | + |
| 85 | +En este tutorial nos enfocaremos en el uso y desarrollo con entornos virtuales. |
| 86 | + |
| 87 | +<p align="right">(<a href="#readme-top">back to top</a>)</p> |
| 88 | + |
| 89 | +### Backend |
| 90 | + |
| 91 | +Para comenzar el backend esta creado con: |
| 92 | + |
| 93 | +- [![Python][python-shield]][python-url] |
| 94 | +- [![FastApi][fastAPI-shield]][fastAPI-url] |
| 95 | + |
| 96 | +<p align="right">(<a href="#readme-top">back to top</a>)</p> |
| 97 | + |
| 98 | +<!-- GETTING STARTED --> |
| 99 | +## Inicio |
| 100 | +The following tools are prior to follow this tutorial and you will be need it running on your machine, however you can find here is a quickly reminder: |
| 101 | +* [![Docker][docker-shield]][docker-url] |
| 102 | +* [![Git][git-shield]][git-url] |
| 103 | +* [![Postman][postman-shield]][postman-url] |
| 104 | +* Your Favorite IDE |
| 105 | +### Prerequisites |
| 106 | + |
| 107 | +This is quick guide of how to install the tools that we will need to use our pre built backend. |
| 108 | +* Git |
| 109 | + * macOS -> Use Homebrew package manager -> [Learn more here][gitMac] |
| 110 | + ```sh |
| 111 | + brew install git |
| 112 | + ``` |
| 113 | + * Linux |
| 114 | + * For distribution based on Debian/Ubuntu |
| 115 | + ```sh |
| 116 | + apt-get install git |
| 117 | + ``` |
| 118 | + * For Fedora |
| 119 | + ```sh |
| 120 | + yum install git |
| 121 | + ``` |
| 122 | + For others distributions, visit [Download Git for Linux/Unix][gitLinux] |
| 123 | + |
| 124 | + * Windows |
| 125 | + |
| 126 | + You can download the latest 32-bit version [Click Here][gitWindows32bit]<br/> |
| 127 | + For other downloads, visit [Dowload git for Windows][gitWindows] |
| 128 | + |
| 129 | +* Docker |
| 130 | + * macOS |
| 131 | + |
| 132 | + * For Mac with Apple silicon [here][dockerapplesilicon] |
| 133 | + * For Mac with Intel chip [here][dockerappleIntel] |
| 134 | + |
| 135 | + For more info visit [Docker Install on Mac][dockermac-url] |
| 136 | + * Windows |
| 137 | + We suggest read this first [Docker install on Windows][windowsDocker-url] |
| 138 | + |
| 139 | + You can download clicking [Desktop][windowsdektop-url] |
| 140 | + |
| 141 | + * Linux/Unix |
| 142 | + |
| 143 | + You can dowload directly [Docker Desktop][linuxdockerdesktop-url] here and follow the instructions, but you must know that in Linux/Unix you have two options and you can read more here [Docker Desktop or Docker Engine][linuxdocker-url] |
| 144 | +### Installing |
| 145 | + |
| 146 | +1. Clone the repo |
| 147 | + ```sh |
| 148 | + git clone https://github.com/molro/backend.git |
| 149 | + ``` |
| 150 | + |
| 151 | +2. Run and stop the backend |
| 152 | + |
| 153 | + - Run the backend |
| 154 | + ``` sh |
| 155 | + docker compose up -d |
| 156 | + ``` |
| 157 | + - Stop the backend |
| 158 | + ``` sh |
| 159 | + docker compose down |
| 160 | + ``` |
| 161 | + |
| 162 | +3. Test the endpoints |
| 163 | + |
| 164 | + Actually the backend has only two endpoints working |
| 165 | + |
| 166 | + 1. GET ``` http://127.0.0.1:3009 ``` - Response status 200 and Json. The first time the reponse will be an empty array ```[] ``` |
| 167 | + 2. POST ``` http://127.0.0.1:3009/crear ``` - Response 200 and OK message and Post a preestablished message |
| 168 | + ```sh |
| 169 | + { |
| 170 | + "_id": str, |
| 171 | + "tipo": "Usuario", |
| 172 | + "estado": "Feliz", |
| 173 | + "__v": 0 |
| 174 | + } |
| 175 | + ``` |
| 176 | + |
| 177 | +4. Code! |
| 178 | + |
| 179 | + Write your code, make the API-REST growing up or connect with your frontend. |
| 180 | + |
| 181 | +5. Testing your code |
| 182 | + - Running the application and review the changes |
| 183 | + ```sh |
| 184 | + docker compose up -d |
| 185 | + ``` |
| 186 | + - Stop the application |
| 187 | + ```sh |
| 188 | + docker compose down |
| 189 | + ``` |
| 190 | + |
| 191 | +8. Add, Commit and Push! |
| 192 | +```sh |
| 193 | + git add . |
| 194 | + git commit -m "Your Commit" |
| 195 | + git push |
| 196 | +``` |
| 197 | +<p align="right">(<a href="#readme-top">back to top</a>)</p> |
| 198 | + |
| 199 | +<!-- ROADMAP --> |
| 200 | +## Roadmap |
| 201 | + |
| 202 | +- [x] Create API-REST version 0.1 |
| 203 | +- [x] Create Dockerfile |
| 204 | +- [x] Create Docker Compose |
| 205 | +- [x] Build Docker Image 0.1 |
| 206 | +- [x] Push image to Docker Hub |
| 207 | +- [x] Create documentation version 0.1 |
| 208 | +- [ ] API-REST version 0.2 |
| 209 | + - [ ] Re-estructure endpoints |
| 210 | + - [ ] Implement authorization method |
| 211 | + - [ ] Create new docker image |
| 212 | + - [ ] Push new version of image |
| 213 | +- [ ] Case of uses section |
| 214 | +- [ ] Troubleshooting |
| 215 | +- [ ] Acknowledgments section |
| 216 | +See the [open issues](https://github.com/molro/backend/issues) for a full list of proposed features (and known issues). |
| 217 | + |
| 218 | +<p align="right">(<a href="#readme-top">back to top</a>)</p> |
| 219 | + |
| 220 | +<!-- LICENSE --> |
| 221 | +## License |
| 222 | + |
| 223 | +Distributed under the GPL License. See [License][license-url] file for more information. |
| 224 | + |
| 225 | +<p align="right">(<a href="#readme-top">back to top</a>)</p> |
| 226 | + |
| 227 | + |
| 228 | + |
| 229 | +<!-- CONTACT --> |
| 230 | +## Contact |
| 231 | + |
| 232 | +[![Twitter][twitter-shield]][twitter-url] [![GitHub][github-shield]][github-url]<br/> |
| 233 | +Project Link: [https://github.com/molro/backend](https://github.com/molro/backend) |
| 234 | + |
| 235 | +<p align="right">(<a href="#readme-top">back to top</a>)</p> |
| 236 | + |
| 237 | + |
| 238 | +<!-- MARKDOWN LINKS & IMAGES --> |
| 239 | +<!-- https://www.markdownguide.org/basic-syntax/#reference-style-links --> |
| 240 | + |
| 241 | + |
| 242 | +[python-shield]:https://img.shields.io/badge/python-3670A0?style=for-the-badge&logo=python&logoColor=ffdd54 |
| 243 | +[python-url]: https://www.python.org |
| 244 | + |
| 245 | +[fastAPI-shield]:https://img.shields.io/badge/FastAPI-005571?style=for-the-badge&logo=fastapi |
| 246 | +[fastAPI-url]:https://fastapi.tiangolo.com |
| 247 | + |
| 248 | +[nodejs-shield]: https://img.shields.io/badge/node.js-6DA55F?style=for-the-badge&logo=node.js&logoColor=white |
| 249 | +[node-url]: https://nodejs.org/en/ |
| 250 | +[expressjs-shield]: https://img.shields.io/badge/express.js-%23404d59.svg?style=for-the-badge&logo=express&logoColor=%2361DAFB |
| 251 | +[expressjs-url]: https://expressjs.com |
| 252 | +[mongoDB-shield]: https://img.shields.io/badge/MongoDB-%234ea94b.svg?style=for-the-badge&logo=mongodb&logoColor=white |
| 253 | +[mongoDB-url]: https://www.mongodb.com |
| 254 | +[mongoose-shield]: https://img.shields.io/badge/mongoose-6.6.5-red |
| 255 | +[mongoose-url]: https://mongoosejs.com |
| 256 | +[docker-shield]:https://img.shields.io/badge/docker-%230db7ed.svg?style=for-the-badge&logo=docker&logoColor=white |
| 257 | +[docker-url]: https://www.docker.com |
| 258 | +[git-shield]:https://img.shields.io/badge/git-%23F05033.svg?style=for-the-badge&logo=git&logoColor=white |
| 259 | +[git-url]: https://git-scm.com |
| 260 | + |
| 261 | +[postman-shield]:https://img.shields.io/badge/Postman-FF6C37?style=for-the-badge&logo=postman&logoColor=white |
| 262 | +[postman-url]: https://www.postman.com |
| 263 | + |
| 264 | + |
| 265 | +[twitter-shield]:https://img.shields.io/twitter/follow/molro?style=social |
| 266 | +[twitter-url]:https://www.twitter.com/molro |
| 267 | +[github-shield]:https://img.shields.io/github/followers/molro?style=social |
| 268 | +[github-url]: https://github.com/molro/ |
| 269 | + |
| 270 | +[gitMac]:https://git-scm.com/download/mac |
| 271 | +[gitLinux]:https://git-scm.com/download/linux |
| 272 | +[gitWindows32bit]:https://github.com/git-for-windows/git/releases/download/v2.38.1.windows.1/Git-2.38.1-32-bit.exe |
| 273 | +[gitWindows]:https://git-scm.com/download/win |
| 274 | + |
| 275 | +[dockerapplesilicon]:https://desktop.docker.com/mac/main/arm64/Docker.dmg?utm_source=docker&utm_medium=webreferral&utm_campaign=docs-driven-download-mac-arm64 |
| 276 | +[dockerappleIntel]:https://desktop.docker.com/mac/main/amd64/Docker.dmg?utm_source=docker&utm_medium=webreferral&utm_campaign=docs-driven-download-mac-amd64 |
| 277 | +[dockermac-url]:https://docs.docker.com/desktop/install/mac-install/ |
| 278 | + |
| 279 | +[windowsDocker-url]:https://docs.docker.com/desktop/install/windows-install/#wsl-2-backend |
| 280 | +[windowsdektop-url]:https://desktop.docker.com/win/main/amd64/Docker%20Desktop%20Installer.exe |
| 281 | + |
| 282 | +[linuxdocker-url]:https://docs.docker.com/desktop/faqs/linuxfaqs/#what-is-the-difference-between-docker-desktop-for-linux-and-docker-engine |
| 283 | +[linuxdockerdesktop-url]:https://docs.docker.com/desktop/install/linux-install/ |
| 284 | + |
| 285 | +[license-url]:https://github.com/molro/backend/blob/main/LICENSE |
0 commit comments