Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F2674065
nu_app.py
ArthurPSmith (Arthur Smith)
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Authored By
ArthurPSmith
Oct 9 2015, 5:08 PM
2015-10-09 17:08:10 (UTC+0)
Size
1 KB
Referenced Files
None
Subscribers
None
nu_app.py
View Options
from
flask
import
Flask
,
request
,
jsonify
,
render_template
,
send_file
from
flask.json
import
JSONEncoder
import
nuclides
app
=
Flask
(
__name__
)
nuclide_provider_class
=
nuclides
.
WdqNuclideProvider
fake_globals
=
{
'isinstance'
:
isinstance
,
'sorted'
:
sorted
}
for
key
in
(
'EmptyCell'
,
'NuclideCell'
):
fake_globals
[
key
]
=
getattr
(
nuclides
,
key
)
@app.before_request
def
set_language
():
app
.
language
=
request
.
args
.
get
(
'lang'
)
if
not
app
.
language
:
available_languages
=
nuclide_provider_class
.
get_available_languages
()
app
.
language
=
request
.
accept_languages
.
best_match
(
available_languages
)
if
not
app
.
language
:
app
.
language
=
'en'
app
.
nuclide_provider
=
nuclide_provider_class
(
app
.
language
)
@app.route
(
'/'
)
def
index
():
"""Render the index page."""
elements
,
table
,
incomplete
=
app
.
nuclide_provider
.
get_table
()
return
render_template
(
'index.html'
,
table
=
table
,
incomplete
=
incomplete
,
**
fake_globals
)
if
__name__
==
'__main__'
:
app
.
run
(
debug
=
True
)
File Metadata
Details
Attached
Mime Type
text/x-python
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2686717
Default Alt Text
nu_app.py (1 KB)
Attached To
Mode
T114547: Table of nuclides based on Wikidata
Attached
Detach File
Event Timeline
Log In to Comment