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
5463dba4
Commit
5463dba4
authored
Dec 22, 2012
by
Priit Laes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add basic (and broken?) methodview example.
parent
3fe3d82d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
63 additions
and
0 deletions
+63
-0
methodview.py
examples/methodview/methodview.py
+44
-0
methodtest.html
examples/methodview/templates/methodtest.html
+12
-0
test.html
examples/methodview/templates/test.html
+7
-0
No files found.
examples/methodview/methodview.py
0 → 100644
View file @
5463dba4
from
flask
import
Flask
,
redirect
,
render_template
,
request
from
flask.ext
import
admin
from
flask.views
import
MethodView
class
ViewWithMethodViews
(
admin
.
BaseView
):
@
admin
.
expose
(
'/'
)
def
index
(
self
):
return
self
.
render
(
'methodtest.html'
)
@
admin
.
expose_plugview
(
'/_api/1'
)
class
API_v1
(
MethodView
):
def
get
(
self
,
cls
):
return
cls
.
render
(
'test.html'
,
request
=
request
,
name
=
"API_v1"
)
def
post
(
self
,
cls
):
return
cls
.
render
(
'test.html'
,
request
=
request
,
name
=
"API_v1"
)
@
admin
.
expose_plugview
(
'/_api/2'
)
class
API_v2
(
MethodView
):
def
get
(
self
,
cls
):
return
cls
.
render
(
'test.html'
,
request
=
request
,
name
=
"API_v2"
)
def
post
(
self
,
cls
):
return
cls
.
render
(
'test.html'
,
request
=
request
,
name
=
"API_v2"
)
# Create flask app
app
=
Flask
(
__name__
,
template_folder
=
'templates'
)
# Flask views
@
app
.
route
(
'/'
)
def
index
():
return
redirect
(
'/admin'
)
if
__name__
==
'__main__'
:
# Create admin interface
admin
=
admin
.
Admin
()
admin
.
add_view
(
ViewWithMethodViews
())
admin
.
init_app
(
app
)
# Start app
app
.
debug
=
True
app
.
run
()
examples/methodview/templates/methodtest.html
0 → 100644
View file @
5463dba4
{% extends 'admin/master.html' %}
{% block body %}
Hello World from MethodTest!
<br/>
<form
method=
"POST"
action=
"{{ url_for('.API_v1') }}"
>
<input
type=
"submit"
value=
"API v1 via POST"
>
<a
href=
"{{ url_for('.API_v1') }}"
>
v1 via GET
</a>
</form>
<form
method=
"POST"
action=
"{{ url_for('.API_v2') }}"
>
<input
type=
"submit"
value=
"API v2 via POST"
>
<a
href=
"{{ url_for('.API_v2') }}"
>
v2 via GET
</a>
</form>
{% endblock %}
examples/methodview/templates/test.html
0 → 100644
View file @
5463dba4
{% extends 'admin/master.html' %}
{% block body %}
This view {{ name }} was accessed using {{ request.method }} request.
<br>
<a
href=
"/"
>
Return
</a>
{% endblock %}
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