M
M
maximkalga2017-03-02 11:53:20
Flask
maximkalga, 2017-03-02 11:53:20

How to login to shell inside Flask project?

How can I login to a shell in a flask so that dependencies from the environment and modules from the project are available so that I can send requests to the ORM like "python manage.py shell" in Django?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
maximkalga, 2017-03-02
@maximkalga

You need to create a shell.py script, give the right to execute chmod +x shell.py.
#!/usr/bin/env python
import os
import readline
from pprint import pprint
from flask import *
from myapp import *
from utils import *
from db import *
from models import *
os.environ['PYTHONINSPECT'] = 'True'
then you can use the shell by running the script ./shell.py
Preconfigured interactive shell

D
Dmitry, 2017-03-02
@EvilsInterrupt

Find Miguel Greenberg's Flask book. This book addresses this issue in great detail.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question