FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
flask-shell-ptpython/flask_shell_ptpython.py at master · xoob/flask-shell-ptpython · GitHub
xoob
flask-shell-ptpython
Repository navigation
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
flask-shell-ptpython
/
flask_shell_ptpython.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
37 lines (26 loc) · 1.04 KB
Breadcrumbs
flask-shell-ptpython
/
flask_shell_ptpython.py
Copy path
File metadata and controls
37 lines (26 loc) · 1.04 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# -*- coding: utf-8 -*-
from
__future__
import
absolute_import
,
division
,
print_function
import
os
import
click
from
flask
.
cli
import
with_appcontext
@
click
.
command
(
'shell'
,
short_help
=
'Runs a shell in the app context.'
)
@
with_appcontext
def
shell_command
():
"""Runs an interactive Python shell in the context of a given
Flask application. The application will populate the default
namespace of this shell according to its configuration.
This is useful for executing small snippets of management code
without having to manually configure the application.
"""
from
flask
.
globals
import
_app_ctx_stack
from
ptpython
.
repl
import
embed
app
=
_app_ctx_stack
.
top
.
app
ctx
=
{}
# Support the regular Python interpreter startup script if someone
# is using it.
startup
=
os
.
environ
.
get
(
'PYTHONSTARTUP'
)
if
startup
and
os
.
path
.
isfile
(
startup
):
with
open
(
startup
,
'r'
)
as
f
:
eval
(
compile
(
f
.
read
(),
startup
,
'exec'
),
ctx
)
ctx
.
update
(
app
.
make_shell_context
())
embed
(
globals
=
ctx
)
Back
|
FazBrowse Home
|
New Git URL