Git Product home page Git Product logo

cloudrun-fastapi's Introduction

cloudrun-fastapi's People

Contributors

anthonycorletti avatar dependabot[bot] avatar takotab avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

cloudrun-fastapi's Issues

Sending Emails with SendGrid

SendGrid is a great choice for sending emails and managing the analytics around them. Checkout their free tier, https://sendgrid.com/free, to get started. In order to send emails, you will have to verify your sending authentication. You can set that up here https://app.sendgrid.com/settings/sender_auth.

In this sample, we'll place all templates in the assets/templates/ directory, located in the project root.

Sample provided from SendGrid:

from sendgrid import SendGridAPIClient
from sendgrid.helpers.mail import Mail

message = Mail(
    from_email='[email protected]',
    to_emails='[email protected]',
    subject='Sending with Twilio SendGrid is Fun',
    html_content='<strong>and easy to do anywhere, even with Python</strong>')
try:
    sg = SendGridAPIClient(api_key=<YOUR_API_KEY>)
    response = sg.send(message=message)
    print(response.status_code)
    print(response.body)
    print(response.headers)
except Exception as e:
    print(e)
    print(e.body)

Cannot connect to local posgres

Hi,

First, thank you a lot for this template. I'm new to the API world and trying to deploy my own one on GCP. But first I'm developing locally. But I'm struggling using the local db.

I first run postgres on a container locally with docker run --rm --name pg-docker -e POSTGRES_DB=postgres_test_db -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=postgres -d -p 5432:5432 -v $HOME/docker/volumes/postgres:/var/lib/postgresql/data postgres:12.3-alpine

Then if I run PYTHONPATH=. alembic revision --autogenerate -m "initial setup", I have the following error message:

...
conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) could not connect to server: No such file or directory
        Is the server running locally and accepting
        connections on Unix domain socket "/tmp/.s.PGSQL.5432"?

In config.py I have url = 'postgresql+psycopg2://postgres:postgres@localhost/postgres_test_db'.

Is there any documentation that could help me?

I'm running everything on Ubuntu (20.04), use vscode and poetry. If I run psql -U postgres -h localhost it connects to the database as expected.

ModuleNotFoundError

When deploying to Cloud Run, this error triggered: ModuleNotFoundError: No module named python container tests.
tests/ was indeed added to .dockerignore

Cannot migrate to Cloud SQL

Hi!

When I'm connecting to my cloud SQL instance with psql "sslmode=disable host=/tmp/cloudsql/PROJECT_ID:REGION:INSTANCE_NAME user=postgres dbname=postgres", it works well but when using:

cloud_sql_proxy -instances=PROJECT_ID:REGION:INSTANCE_NAME -dir=/tmp/cloudsql

And then doing:

PYTHONPATH=. alembic revision --autogenerate -m "initial setup"

I have the error:

...
sqlalchemy.exc.ArgumentError: Could not parse rfc1738 URL from string 'PROJECT_ID:REGION:INSTANCE_NAME'

(PROJECT_ID:REGION:INSTANCE_NAME being my own instance)

Any idea or documentation to solve this issue?

View docs when cloud run service is on a custom domain

Hi! Thanks for this repo.

Quick q, I am able to view docs on the raw cloud run domain, but I am using a custom domain mapping so all my services are reachable at customdomain.com/{service-name}, this works fine for all uses apart from the docs are not available at customdomain.com/{service-name}/docs

Any idea why that could be the case?

Question about the Gunicorn config

Hey,
thanks for the project and your work. I have a question about the Gunicorn config. The official Cloud Run tutorial for Python applications (in this case Flask and not async) states that this config should be used:

CMD exec gunicorn --bind :$PORT --workers 1 --threads 8 --timeout 0 main:app

I understand that this might not be the best config for FastAPI applications but they explicitly say that "Timeout is set to 0 to disable the timeouts of the workers to allow Cloud Run to handle instance scaling."

So is there a reason to use your timeout value of 60 instead of the recommended one?

Thanks!

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.