Giter Club home page Giter Club logo

flask_project_setup's Introduction

Hi there, I'm Leo

Github Badge Stackoverflow Badge Twitter Badge Linkedin Badge

Born in 1977, I started coding in April 1987 on a Sinclair ZX Spectrum. I then moved to MS-DOS PCs and in 1996 I started using Linux and became interested in operating system internals. I love architectures, algorithms, mathematics and cryptography. I currently work as an infrastructure engineer and Python developer.

From 2013 I blog some technical thoughts at The Digital Cat

In 2018 I published the free book "Clean Architectures in Python” that is available on Leanpub and online.

Open source projects:

Languages and Tools:

Linux Bash Python AWS Docker NGINX Terraform



Github Stats

lgiordani's Github Stats

flask_project_setup's People

Contributors

lgiordani avatar

Stargazers

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

Watchers

 avatar  avatar

flask_project_setup's Issues

error because of the port number.

I appreciate for your amazing work.

I would like to explain the error which was already issued(#4) for you to catch up easily.

You can face the error the stage, 'Scenario example 1' in the 'Flask project set up Part3'

As far as I understand, the error is started from the line.

cmdline = docker_compose_cmdline("up -d")

and, it counter the error in here because web service run the flask application.
port = os.environ["POSTGRES_PORT"]

when the web service container run, it needs port number for postgresql, but there is no information for port number at that time.

I'm looking forward to your reply
Again, huge thanks for your work.

flask.cli.NoAppException: Could not import "wsgi".

Hi,

Thanks for the great blog.
I am having trouble executing the part 1. After executing
"docker-compose -f docker/development.yml up -d", going to 0.0.0.0:5000, results in NoAppException.

Can you please let me know how to resolve this? Thanks in advance.

Regards,
Prabhakar

Scenario Up db connect broken

Line 211 in manage.py results in a connection to a container with no env variables set up. The container is built correctly but something strange happens with the current connection string. This is my work around, would love your thoughts. The tutorial is beautiful.

docker_output_json = subprocess.check_output(['docker','ps',"--format='{{ json .Names}}'"])

docker_startup_names = docker_output_json.decode('unicode_escape').split('"')

scenario_db_name = [ x for x in docker_startup_names if config and 'db' in x ][0]

cmdline = f"docker exec -it {scenario_db_name} psql -U {os.getenv('POSTGRES_USER')} -d {os.getenv('APPLICATION_DB')}"

Service `web` in scenario.yml starts before POSTGRES_PORT is set

Thanks for the great tutorial, it's super helpful.

I got the error below when running the first scenario, and looking at how the code in manage.py is structured:

cmdline = docker_compose_cmdline('up -d') starts both database and web services, before the port is set a few lines down
port = out.decode('utf-8').replace('\n', '').split(':')[1]
os.environ['POSTGRES_PORT'] = port

* Environment: development
 * Debug mode: on
Traceback (most recent call last):
  File "/usr/local/bin/flask", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.9/site-packages/flask/cli.py", line 990, in main
    cli.main(args=sys.argv[1:])
  File "/usr/local/lib/python3.9/site-packages/flask/cli.py", line 596, in main
    return super().main(*args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1062, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1668, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 763, in invoke
    return __callback(*args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/click/decorators.py", line 84, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 763, in invoke
    return __callback(*args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/flask/cli.py", line 845, in run_command
    app = DispatchingApp(info.load_app, use_eager_loading=eager_loading)
  File "/usr/local/lib/python3.9/site-packages/flask/cli.py", line 321, in __init__
    self._load_unlocked()
  File "/usr/local/lib/python3.9/site-packages/flask/cli.py", line 346, in _load_unlocked
    self._app = rv = self.loader()
  File "/usr/local/lib/python3.9/site-packages/flask/cli.py", line 406, in load_app
    app = locate_app(self, import_name, None, raise_if_not_found=False)
  File "/usr/local/lib/python3.9/site-packages/flask/cli.py", line 256, in locate_app
    __import__(module_name)
  File "/opt/code/wsgi.py", line 5, in <module>
    app = create_app(os.environ['FLASK_CONFIG'])
  File "/opt/code/application/app.py", line 10, in create_app
    app.config.from_object(config_module)
  File "/usr/local/lib/python3.9/site-packages/flask/config.py", line 161, in from_object
    obj = import_string(obj)
  File "/usr/local/lib/python3.9/site-packages/werkzeug/utils.py", line 865, in import_string
    __import__(import_name)
  File "/opt/code/application/config.py", line 6, in <module>
    class Config(object):
  File "/opt/code/application/config.py", line 12, in Config
    port = os.environ['POSTGRES_PORT']
  File "/usr/local/lib/python3.9/os.py", line 679, in __getitem__
    raise KeyError(key) from None
KeyError: 'POSTGRES_PORT'

License question

Hi,

Wow, this is just what I was looking for! Thank you so much.

I would like to copy your code but I can't find the License, so I don't know if I can.

Could you point me in the right direction please?

Cheers!

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.