Git Product home page Git Product logo

curso-fastapi's Introduction

Dos formas de ejecutar fastapi

1. uvicorn main:app en la terminal
2. Agregar las líneas de código:
    import uvicorn
    if __name__=="__main__":
        uvicorn.run("main:app", port=8000)

    Y luego correr main.py

Realizar Migraciones

alembic init migrations

configurar alembic

- abrir el alembic.ini y modificar la línea de sqlalchemy.url y dejar vacío.

Abrir el env.py de la carpeta migrations

Copiar esto antes de la función run_migrations_offline
from core.config import settings

config = context.config
config.set_main_option('sqlalchemy.url', settings.DATABASE_URL)

if config.config_file_name is not None:
    fileConfig(config.config_file_name)

from app.db.models import Base
target_metadata = Base.metadata

Por último ejecutar

alembic revision --autogenerate -m "crear modelos" alembic upgrade heads

Desplegar en heroku

Descargar el cli de heroku https://devcenter.heroku.com/articles/heroku-cli

1. heroku login
2. heroku git:remote -a URL_PROYECTO
3. git push heroku master

curso-fastapi's People

Watchers

Borja Cabadas Dosantos 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.