Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
oldroco
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container Registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mehtank
oldroco
Commits
e4c417a0
Commit
e4c417a0
authored
5 years ago
by
mehtank
Browse files
Options
Downloads
Patches
Plain Diff
Handle widgets
parent
b3c21792
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
flaskapp/app.py
+4
-2
4 additions, 2 deletions
flaskapp/app.py
flaskapp/widgets.py
+11
-0
11 additions, 0 deletions
flaskapp/widgets.py
with
15 additions
and
2 deletions
flaskapp/app.py
+
4
−
2
View file @
e4c417a0
from
flask
import
Flask
,
render_template
,
request
,
send_from_directory
,
abort
,
jsonify
,
Response
from
flask_cors
import
CORS
from
wtforms
import
Form
,
IntegerField
,
SubmitField
from
wtforms
import
Form
from
widgets
import
*
from
os.path
import
join
import
traceback
...
...
@@ -115,7 +116,8 @@ def catchall(path):
class
ParamForm
(
Form
):
pass
for
k
,
v
in
f
.
parameters
.
iteritems
():
setattr
(
ParamForm
,
k
,
IntegerField
(
"
%s:
"
%
k
,
default
=
v
))
md
=
f
.
metadata
.
get
(
k
,
{})
setattr
(
ParamForm
,
k
,
MyField
(
"
%s:
"
%
k
,
md
,
default
=
v
))
return
render_template
(
"
combined.html
"
,
component
=
component
,
query
=
request
.
query_string
,
form
=
ParamForm
())
print
component
...
...
This diff is collapsed.
Click to expand it.
flaskapp/widgets.py
0 → 100644
+
11
−
0
View file @
e4c417a0
from
wtforms.fields.html5
import
DecimalField
from
wtforms.widgets
import
html5
as
widgets
class
MyField
(
DecimalField
):
def
__init__
(
self
,
label
=
None
,
md
=
None
,
**
kwargs
):
super
(
DecimalField
,
self
).
__init__
(
label
,
**
kwargs
)
self
.
widget
=
widgets
.
NumberInput
()
if
md
:
self
.
widget
.
min
=
md
.
get
(
"
min
"
,
None
)
self
.
widget
.
max
=
md
.
get
(
"
max
"
,
None
)
self
.
widget
.
step
=
md
.
get
(
"
step
"
,
None
)
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment