Questions tagged [flask-script]

61 questions
71
votes
7 answers

Run code after flask application has started

My goal is to get arbitrary code to run after my Flask application is started. Here is what I've got: def run(): from webapp import app app.run(debug=True, use_reloader=False) Ideally I would be able to just do this: def run(): from…
kai
  • 1,288
  • 3
  • 12
  • 24
19
votes
4 answers

Use Flask's Click CLI with the app factory pattern

I define my Flask application using the app factory pattern. When using Flask-Script, I can pass the factory function to the Manager. I'd like to use Flask's built-in Click CLI instead. How do I use the factory with Click? My current code uses…
user3313834
  • 7,327
  • 12
  • 56
  • 99
14
votes
1 answer

Blueprint initialization, can I run a function before first request to blueprint

Is it possible to run a function before the first request to a specific blueprint? @my_blueprint.before_first_request def init_my_blueprint(): print 'yes' Currently this will yield the following error: AttributeError: 'Blueprint' object has no…
pyCthon
  • 11,746
  • 20
  • 73
  • 135
10
votes
1 answer

Flask database migrations on heroku

With my app I am using flask-script and flask-migrate for database migrations, everything works locally. When, I run heroku run python manage.py db init It creates this output: Running python manage.py db init on ⬢ fpds-scheduler... up, run.1290…
spitfiredd
  • 2,897
  • 5
  • 32
  • 75
10
votes
2 answers

deploying flask app with uwsgi and flask-script Manager

Traditionally, I have configured the UWSGI configuration file to call an application like below: mydirectory/uwsgi_application.ini ... #python module to import app = run_web module = %(app) callable = app ... , mydirectory/run_web.py from ersapp…
Brian Leach
  • 3,974
  • 8
  • 36
  • 75
9
votes
1 answer

using flask-migrate with flask-script and application factory

I'm building flask application and decided to try application factory approach this time, but got into trouble with flask-migrate and can't figure out simple solution. Please note that I want to pass config location as an option to the…
ETK
  • 115
  • 2
  • 5
8
votes
4 answers

importerror: no module named flask.ext.script

In fact I cannot use any pakage now! importerror: no module named flask.ext.script importerror: no module named Pymongo
Mark White
  • 640
  • 1
  • 5
  • 12
6
votes
1 answer

Restart flask app in docker on changes

I am using flask-script to run my app: if __name__ == "__main__": manager.run() In docker I have the following: CMD [ "python", "manage.py", "runserver", "-h", "0.0.0.0", "-p", "5000"] Now when I build and run my container the app runs fine.…
user1686342
  • 1,265
  • 1
  • 18
  • 24
6
votes
1 answer

Run app from Flask-Migrate manager

I used these lines to start my application: from app import app app.run(host='0.0.0.0', port=8080, debug=True) Using Flask-Migrate, I have this instead: from app import manager manager.run() manager.run does not take the same arguments as app.run,…
rablentain
  • 6,641
  • 13
  • 50
  • 91
5
votes
1 answer

Is there a way to run initialization code in each uwsgi worker (after forking)

Is there a way (in uWSGI or Flask) to register a function to be run in each worker after spawning but as soon as possible? We have a flask app that benefits from preloading a bunch of stuff. The following only calls preload once for the 8 worker…
jmilloy
  • 7,875
  • 11
  • 53
  • 86
5
votes
1 answer

using flask-migrate with flask-script, flask-socketio and application factory

I'm creating an flask application with the application factory approach, but have an issue when using Flask-Migrate with socketio and flask-script. The problem is that I'm passing my create_app function to the Manager but I need to pass the app to…
Zyber
  • 1,034
  • 8
  • 19
4
votes
1 answer

how to set default values in @manager.options in flask-script

I have built a command line python script using flask-script package to access an sql database that a regular APIRest service is managing via flask. I am having trouble setting parameters for my script commands. In particular: a) How to set a…
XAnguera
  • 1,157
  • 1
  • 11
  • 25
4
votes
1 answer

Flask-Script How to get to the current app?

I'm trying to get access to the current app instance from a Flask-Script manager.command. This errors out (url_map is a property of flask.app) @manager.command def my_function(): x = app.url_map # this fails, because app is a callable …
101010
  • 14,866
  • 30
  • 95
  • 172
4
votes
1 answer

Flask-Script add_option method not working

Using flask-script's add_option method I'm trying to pass the name of a config file into my create_app() so I can configure from_pyfile() -- Flask Instance Folders I used this gist to get me started. manage.py from fbone import create_app app =…
frankV
  • 5,353
  • 8
  • 33
  • 46
3
votes
1 answer

Get debug status out of Flask Script Manager

I'm using Flask-Script and I've got a manage.py that looks like this. from mypackage import create_app from flask.ext.script import Manager app = create_app() manager = Manager(app) if __name__ == '__main__': manager.run() I'll start my…
Everett Toews
  • 10,337
  • 10
  • 44
  • 45
1
2 3 4 5