miguelgrinberg / flasky

Companion code to my O'Reilly book "Flask Web Development", second edition.
MIT License
8.52k stars 4.2k forks source link

Flask run command doesn't work #559

Closed nickmeny closed 10 months ago

nickmeny commented 10 months ago

Hi,recently i bought your book and i am completly satisfied from your job!!! But, i want to implement your code at my project, specially the file organization. I make the config.py file as you have done in the book at page 87 with the only difference i loaded the var form a .env file . When i want to start the server at my pc i get that error

Usage: flask run [OPTIONS]
Try 'flask run --help' for help.

Error: Detected factory 'create_app' in module 'app', but could not call it without arguments. Use 'app:create_app(args)' to specify arguments.

i have done everything up to page 97!!! pls help me (i have name the flasky.py file to app.py)

miguelgrinberg commented 10 months ago

Looks like you did not set your FLASK_APP environment variable.

nickmeny commented 10 months ago

Looks like you did not set your FLASK_APP environment variable.

I have set the env var with the command set FLASK_APP=app.py

miguelgrinberg commented 10 months ago

Okay, so then in app.py you are not creating an application instance. See flasky.py in this repository and compare that against your app.py.

nickmeny commented 10 months ago

i found the solution!!! For dome reason my file name app.py dowsnt work with flask!!! When i rename it to flasky.py and set the FLASK_APP=flasky.py everything worked !!!

miguelgrinberg commented 10 months ago

Did you have both app.py and the app package? That could be the problem, Python will see only one of them, since both have the name app.

nickmeny commented 10 months ago

Oh yes I had. That was the problem. Thanks any way for your help