Commit f9052ee80da3c7905c9fd9d8e2ffb1dcbf8d848e
1 parent
e81a9130
Exists in
master
barrabrasil.py: corre??o da fonte. build.sh: modifica??o na data. profile.py: adicionando profiling
Showing
5 changed files
with
15 additions
and
15 deletions
Show diff stats
LEIAME
| @@ -32,6 +32,11 @@ Dependências: | @@ -32,6 +32,11 @@ Dependências: | ||
| 32 | # sass -v | 32 | # sass -v |
| 33 | - uglifyjs | 33 | - uglifyjs |
| 34 | # sudo npm install -g uglify-js | 34 | # sudo npm install -g uglify-js |
| 35 | + - zlib | ||
| 36 | + | ||
| 37 | +Para profiling é necessário além dos acima | ||
| 38 | + | ||
| 39 | + - werkzeug | ||
| 35 | 40 | ||
| 36 | Requisitos da Barra | 41 | Requisitos da Barra |
| 37 | 42 |
app/barrabrasil.py
| @@ -54,23 +54,11 @@ def barra(): | @@ -54,23 +54,11 @@ def barra(): | ||
| 54 | resposta = make_response(conteudo) | 54 | resposta = make_response(conteudo) |
| 55 | resposta.set_etag(etag) | 55 | resposta.set_etag(etag) |
| 56 | resposta.headers['Content-type'] = 'application/x-javascript' | 56 | resposta.headers['Content-type'] = 'application/x-javascript' |
| 57 | - resposta.headers['Cache-control'] = 'public, max-age: 86401' #24 horas | ||
| 58 | - resposta.headers['Last-Modified'] = data | ||
| 59 | - return resposta | ||
| 60 | - | ||
| 61 | -@app.route('/static/opensans-bold.woff') | ||
| 62 | -def fonte(): | ||
| 63 | - f = app.open_resource('profile') | ||
| 64 | - cfg = Config(f) | ||
| 65 | - data = cfg.date | ||
| 66 | - f = app.open_resource('static/opensans-bold.woff') | ||
| 67 | - conteudo = f.read().decode('base64') | ||
| 68 | - resposta = make_response(conteudo) | ||
| 69 | - resposta.headers['Content-type'] = 'application/x-font-woff' | ||
| 70 | resposta.headers['Cache-control'] = 'public, max-age: 31536000' #1 ano | 57 | resposta.headers['Cache-control'] = 'public, max-age: 31536000' #1 ano |
| 71 | resposta.headers['Last-Modified'] = data | 58 | resposta.headers['Last-Modified'] = data |
| 72 | return resposta | 59 | return resposta |
| 73 | 60 | ||
| 61 | + | ||
| 74 | if __name__ == '__main__': | 62 | if __name__ == '__main__': |
| 75 | import webbrowser | 63 | import webbrowser |
| 76 | webbrowser.open("http://127.0.0.1:5000/",new=2) | 64 | webbrowser.open("http://127.0.0.1:5000/",new=2) |
app/profile
| @@ -0,0 +1,7 @@ | @@ -0,0 +1,7 @@ | ||
| 1 | +#!flask/bin/python | ||
| 2 | +from werkzeug.contrib.profiler import ProfilerMiddleware | ||
| 3 | +from barrabrasil import app | ||
| 4 | + | ||
| 5 | +app.config['PROFILE'] = True | ||
| 6 | +app.wsgi_app = ProfilerMiddleware(app.wsgi_app, restrictions = [30]) #30 que mais demoraram | ||
| 7 | +app.run(debug = True) |
build.sh
| @@ -14,7 +14,7 @@ then | @@ -14,7 +14,7 @@ then | ||
| 14 | cd ../../app | 14 | cd ../../app |
| 15 | touch profile | 15 | touch profile |
| 16 | echo 'profile :' $profile > profile | 16 | echo 'profile :' $profile > profile |
| 17 | - echo 'date : "' $(date -R) '"'>> profile | 17 | + echo 'date : "'$(date -R)'"'>> profile |
| 18 | python barrabrasil.py | 18 | python barrabrasil.py |
| 19 | else | 19 | else |
| 20 | echo "Error. Profile $1 does not exist." | 20 | echo "Error. Profile $1 does not exist." |