flask-script

Flask database migrations on heroku

你离开我真会死。 提交于 2020-05-10 06:26:19
问题 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 (Free) Creating directory /app/migrations ... done Creating directory /app/migrations/versions ... done Generating /app/migrations/README ... done Generating /app/migrations/script.py.mako ... done Generating /app/migrations/alembic.ini ... done

Flask database migrations on heroku

二次信任 提交于 2020-05-10 06:24:07
问题 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 (Free) Creating directory /app/migrations ... done Creating directory /app/migrations/versions ... done Generating /app/migrations/README ... done Generating /app/migrations/script.py.mako ... done Generating /app/migrations/alembic.ini ... done

Reading from standard input using Flask-Script / Python

痴心易碎 提交于 2019-12-12 12:35:32
问题 Right now I have flask-script command that takes a path as an argument, then reads from the path: @manager.option('-f', '--file', dest='file_path') def my_command(file_path): open(file_path) ... I'd want it to be able to read from standard in as well. (I frequently need to pass it text on the clipboard, and it's annoying to have to create a file each time.) How can I accomplish this? I've tried using fileinput.input() , via this https://stackoverflow.com/a/1454400/1164573, invoked with the

Why is Cassandra hanging when I connect to it via Gunicorn and Flask?

左心房为你撑大大i 提交于 2019-12-12 03:27:49
问题 I have a Flask app that connects to Cassandra. When I run this app under Gunicorn and invoke Gunicorn as a flask-script command python manage.py gunicorn , it hangs. But when I run this same app on the command line as gunicorn manage:app , it succeeds. Why? 回答1: Explanation Gunicorn forks off workers to handle incoming requests. If the Cassandra session (connection pool) is created before the worker fork (e.g., during app creation using an application factory pattern), the workers will have

importerror: no module named flask.ext.script

谁说胖子不能爱 提交于 2019-12-09 16:57:30
问题 In fact I cannot use any pakage now! importerror: no module named flask.ext.script importerror: no module named Pymongo 回答1: It seems that you virtual environment doesn't work. You've installed the flask-script package, but when you run the script, it still looks for it in C:\Python3.4 . You may give us more info so that we can figure it out where is wrong. (How do you install it, how do you active the virtualenv, does reinstall virtualenv work, close the cmd shell and try again works?) Also

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

时光怂恿深爱的人放手 提交于 2019-12-07 08:20:49
问题 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 my socketio.run() as well. And right now I can't seem to see a solution. Is there any way I can combine these two solutions? manage.py: #app = create_app(False) <--- Old approach #manager = flask_script.Manager(app) manager = flask_script.Manager

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

和自甴很熟 提交于 2019-12-06 23:23:59
问题 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 attribute 'before_first_request' 回答1: The Blueprint equivalent is called @Blueprint.before_app_first_request: @my_blueprint.before_app_first_request def init_my_blueprint(): print('yes') The name reflects that it is called before any request, not just

deploying flask app with uwsgi and flask-script Manager

只愿长相守 提交于 2019-12-05 22:49:35
问题 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 import app if __name__ == "__main__": app.run() , mydirectory/ersapp/__init__.py ... app = Flask('ersapp') ... But now, I am following Miguel Grinberg's Flask book and here he uses an application factory like below mydirectory/ersapp/__init__.py ...

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

六月ゝ 毕业季﹏ 提交于 2019-12-05 12:48:05
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 my socketio.run() as well. And right now I can't seem to see a solution. Is there any way I can combine these two solutions? manage.py: #app = create_app(False) <--- Old approach #manager = flask_script.Manager(app) manager = flask_script.Manager(create_app) manager.add_option("-t", "--testing", dest="testing", required=False) manager.add_command(

Restart flask app in docker on changes

前提是你 提交于 2019-12-05 07:22:43
问题 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. However, if I make changes to my code and save the app does not restart despite my env having a DEBUG=True variable set. Am I missing something here? Dockerfile: FROM python:3.4-slim RUN apt-get update -y && \ apt-get install -y \ python-pip \ python-dev