Git Product home page Git Product logo

learn-fastapi-ifood's Introduction

learn-fastapi-ifood

Tutorial feito pras quartas de desenvolvimento

Requisitos

  • Python 3.6+
  • Docker

Primeiro vamos instalar os requisitos no arquivo requirements.txt

pip install -r requirements.txt

Exemplo 1: Hello World

Execute o seguinte comando no terminal

uvicorn hello:app --reload

Se funcionou corretamente o terminal vai printar o seguinte:

INFO:     Will watch for changes in these directories: ['/home/lucas-sossai/dev-pessoal/learn-fastapi-ifood']
INFO:     Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
INFO:     Started reloader process [43848] using statreload
INFO:     Started server process [43850]
INFO:     Waiting for application startup.
INFO:     Application startup complete.

Para verificar o funcionamento entre no endereço http://127.0.0.1:8000 e veja se a seguinte mensagem chegou: {"detail":"Hello World!"}

Você pode checar a docs automática pelo endpoint http://127.0.0.1:8000/docs

Exemplo 2: Create User

Primeiro vamos dar deploy num postgres local para a API se comunicar. Execute o script deploy_local_postgres.sh

sh deploy_local_postgres.sh

Através do DBeaver ou outro sistema de preferência verifique se o banco está no ar

  • host: 127.0.0.1
  • port: 5432
  • user: postgres
  • password: 1234

Agora vamos dar deploy na API com o seguinte comando:

uvicorn main:app --reload

Entre na docs http://127.0.0.1:8000/docs e teste a criação de usuário, depois verifique se foi salvo no banco Postgres.

learn-fastapi-ifood's People

Contributors

lsossai avatar

Stargazers

 avatar Carol Carvalho avatar Elton N. avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.