Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
flask-admin
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Python-Dev
flask-admin
Commits
e5ad1ea8
Commit
e5ad1ea8
authored
Nov 28, 2013
by
Petrus J.v.Rensburg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Only build sample db's if they don't exist yet.
parent
ba1f5f38
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
34 additions
and
12 deletions
+34
-12
auth.py
examples/auth/auth.py
+9
-4
simple.py
examples/forms/simple.py
+7
-2
simple.py
examples/layout/simple.py
+10
-3
simple.py
examples/sqla/simple.py
+8
-3
No files found.
examples/auth/auth.py
View file @
e5ad1ea8
import
os
from
flask
import
Flask
,
url_for
,
redirect
,
render_template
,
request
from
flask.ext.sqlalchemy
import
SQLAlchemy
from
wtforms
import
form
,
fields
,
validators
from
flask.ext
import
admin
,
login
from
flask.ext.admin.contrib
import
sqla
from
flask.ext.admin
import
helpers
,
expose
# Create Flask application
app
=
Flask
(
__name__
)
...
...
@@ -14,7 +14,8 @@ app = Flask(__name__)
app
.
config
[
'SECRET_KEY'
]
=
'123456790'
# Create in-memory database
app
.
config
[
'SQLALCHEMY_DATABASE_URI'
]
=
'sqlite:///sample.sqlite'
app
.
config
[
'DATABASE_FILE'
]
=
'sample_db.sqlite'
app
.
config
[
'SQLALCHEMY_DATABASE_URI'
]
=
'sqlite:///'
+
app
.
config
[
'DATABASE_FILE'
]
app
.
config
[
'SQLALCHEMY_ECHO'
]
=
True
db
=
SQLAlchemy
(
app
)
...
...
@@ -195,7 +196,11 @@ def build_sample_db():
if
__name__
==
'__main__'
:
build_sample_db
()
# Build a sample db on the fly, if one does not exist yet.
app_dir
=
op
.
realpath
(
os
.
path
.
dirname
(
__file__
))
database_path
=
op
.
join
(
app_dir
,
app
.
config
[
'DATABASE_FILE'
])
if
not
os
.
path
.
exists
(
database_path
):
build_sample_db
()
# Start app
app
.
run
(
debug
=
True
)
examples/forms/simple.py
View file @
e5ad1ea8
...
...
@@ -19,7 +19,8 @@ app = Flask(__name__, static_folder='files')
app
.
config
[
'SECRET_KEY'
]
=
'123456790'
# Create in-memory database
app
.
config
[
'SQLALCHEMY_DATABASE_URI'
]
=
'sqlite:///sample.sqlite'
app
.
config
[
'DATABASE_FILE'
]
=
'sample_db.sqlite'
app
.
config
[
'SQLALCHEMY_DATABASE_URI'
]
=
'sqlite:///'
+
app
.
config
[
'DATABASE_FILE'
]
app
.
config
[
'SQLALCHEMY_ECHO'
]
=
True
db
=
SQLAlchemy
(
app
)
...
...
@@ -241,7 +242,11 @@ def build_sample_db():
if
__name__
==
'__main__'
:
build_sample_db
()
# Build a sample db on the fly, if one does not exist yet.
app_dir
=
op
.
realpath
(
os
.
path
.
dirname
(
__file__
))
database_path
=
op
.
join
(
app_dir
,
app
.
config
[
'DATABASE_FILE'
])
if
not
os
.
path
.
exists
(
database_path
):
build_sample_db
()
# Start app
app
.
run
(
debug
=
True
)
\ No newline at end of file
examples/layout/simple.py
View file @
e5ad1ea8
import
os
from
flask
import
Flask
from
flask.ext.sqlalchemy
import
SQLAlchemy
from
flask.ext
import
admin
,
wtf
from
flask.ext
import
admin
from
flask.ext.admin.contrib.sqla
import
ModelView
# Create application
app
=
Flask
(
__name__
)
...
...
@@ -11,7 +13,8 @@ app = Flask(__name__)
app
.
config
[
'SECRET_KEY'
]
=
'123456790'
# Create in-memory database
app
.
config
[
'SQLALCHEMY_DATABASE_URI'
]
=
'sqlite:///sample_db.sqlite'
app
.
config
[
'DATABASE_FILE'
]
=
'sample_db.sqlite'
app
.
config
[
'SQLALCHEMY_DATABASE_URI'
]
=
'sqlite:///'
+
app
.
config
[
'DATABASE_FILE'
]
app
.
config
[
'SQLALCHEMY_ECHO'
]
=
True
db
=
SQLAlchemy
(
app
)
...
...
@@ -135,7 +138,11 @@ def build_sample_db():
if
__name__
==
'__main__'
:
build_sample_db
()
# Build a sample db on the fly, if one does not exist yet.
app_dir
=
op
.
realpath
(
os
.
path
.
dirname
(
__file__
))
database_path
=
op
.
join
(
app_dir
,
app
.
config
[
'DATABASE_FILE'
])
if
not
os
.
path
.
exists
(
database_path
):
build_sample_db
()
# Start app
app
.
run
(
debug
=
True
)
examples/sqla/simple.py
View file @
e5ad1ea8
import
os
from
flask
import
Flask
from
flask.ext.sqlalchemy
import
SQLAlchemy
...
...
@@ -7,7 +8,6 @@ from flask.ext import admin
from
flask.ext.admin.contrib
import
sqla
from
flask.ext.admin.contrib.sqla
import
filters
from
flask.ext
import
wtf
# Create application
app
=
Flask
(
__name__
)
...
...
@@ -16,7 +16,8 @@ app = Flask(__name__)
app
.
config
[
'SECRET_KEY'
]
=
'123456790'
# Create in-memory database
app
.
config
[
'SQLALCHEMY_DATABASE_URI'
]
=
'sqlite:///sample_db.sqlite'
app
.
config
[
'DATABASE_FILE'
]
=
'sample_db.sqlite'
app
.
config
[
'SQLALCHEMY_DATABASE_URI'
]
=
'sqlite:///'
+
app
.
config
[
'DATABASE_FILE'
]
app
.
config
[
'SQLALCHEMY_ECHO'
]
=
True
db
=
SQLAlchemy
(
app
)
...
...
@@ -261,7 +262,11 @@ def build_sample_db():
if
__name__
==
'__main__'
:
build_sample_db
()
# Build a sample db on the fly, if one does not exist yet.
app_dir
=
op
.
realpath
(
os
.
path
.
dirname
(
__file__
))
database_path
=
op
.
join
(
app_dir
,
app
.
config
[
'DATABASE_FILE'
])
if
not
os
.
path
.
exists
(
database_path
):
build_sample_db
()
# Start app
app
.
run
(
debug
=
True
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment