Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
T
Taiko Web
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nanahira
Taiko Web
Commits
d92cd6f3
Commit
d92cd6f3
authored
Feb 14, 2019
by
Bui
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add view caching
parent
ca85bc1b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
0 deletions
+10
-0
app.py
app.py
+10
-0
No files found.
app.py
View file @
d92cd6f3
...
@@ -4,12 +4,19 @@ from __future__ import division
...
@@ -4,12 +4,19 @@ from __future__ import division
import
json
import
json
import
sqlite3
import
sqlite3
import
tempfile
import
re
import
re
import
os
import
os
from
flask
import
Flask
,
g
,
jsonify
,
render_template
,
request
,
abort
,
redirect
from
flask
import
Flask
,
g
,
jsonify
,
render_template
,
request
,
abort
,
redirect
from
flask_caching
import
Cache
from
ffmpy
import
FFmpeg
from
ffmpy
import
FFmpeg
app
=
Flask
(
__name__
)
app
=
Flask
(
__name__
)
try
:
app
.
cache
=
Cache
(
app
,
config
=
{
'CACHE_TYPE'
:
'redis'
})
except
RuntimeError
:
app
.
cache
=
Cache
(
app
,
config
=
{
'CACHE_TYPE'
:
'filesystem'
,
'CACHE_DIR'
:
tempfile
.
gettempdir
()})
DATABASE
=
'taiko.db'
DATABASE
=
'taiko.db'
DEFAULT_URL
=
'https://github.com/bui/taiko-web/'
DEFAULT_URL
=
'https://github.com/bui/taiko-web/'
...
@@ -149,6 +156,7 @@ def route_index():
...
@@ -149,6 +156,7 @@ def route_index():
@
app
.
route
(
'/api/preview'
)
@
app
.
route
(
'/api/preview'
)
@
app
.
cache
.
cached
(
timeout
=
15
)
def
route_api_preview
():
def
route_api_preview
():
song_id
=
request
.
args
.
get
(
'id'
,
None
)
song_id
=
request
.
args
.
get
(
'id'
,
None
)
if
not
song_id
or
not
re
.
match
(
'^[0-9]+$'
,
song_id
):
if
not
song_id
or
not
re
.
match
(
'^[0-9]+$'
,
song_id
):
...
@@ -167,6 +175,7 @@ def route_api_preview():
...
@@ -167,6 +175,7 @@ def route_api_preview():
@
app
.
route
(
'/api/songs'
)
@
app
.
route
(
'/api/songs'
)
@
app
.
cache
.
cached
(
timeout
=
15
)
def
route_api_songs
():
def
route_api_songs
():
songs
=
query_db
(
'select * from songs where enabled = 1'
)
songs
=
query_db
(
'select * from songs where enabled = 1'
)
...
@@ -210,6 +219,7 @@ def route_api_songs():
...
@@ -210,6 +219,7 @@ def route_api_songs():
@
app
.
route
(
'/api/config'
)
@
app
.
route
(
'/api/config'
)
@
app
.
cache
.
cached
(
timeout
=
15
)
def
route_api_config
():
def
route_api_config
():
config
=
get_config
()
config
=
get_config
()
return
jsonify
(
config
)
return
jsonify
(
config
)
...
...
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