Muestra las diferencias entre dos versiones de la página.
| Ambos lados, revisión anterior Revisión previa Próxima revisión | Revisión previa | ||
|
wiki2:python:flask [2015/08/09 16:04] alfred [Blueprints] |
wiki2:python:flask [2020/05/09 09:25] (actual) |
||
|---|---|---|---|
| Línea 1: | Línea 1: | ||
| ====== Flask ====== | ====== Flask ====== | ||
| + | ===== Extensions ===== | ||
| + | |||
| + | * [[wiki2:python:flask:sqlalchemy|Flask SQLAlchemy]] | ||
| + | * [[wiki2:python:flask:restful|Flask RESTful]] | ||
| + | * [[wiki2:python:flask:mongoalchemy|Flask MongoAlchemy]] | ||
| + | * [[wiki2:python:flask:flaskmongoengine|Flask Mongo Engine]] | ||
| + | * [[wiki2:python:flask:flasklogin|Flask Login]] | ||
| + | * [[wiki2:python:flask:testing|Flask Testing]] | ||
| + | * [[wiki2:python:flask:used_libraries|Flask used libraries]] | ||
| ===== Some elements ===== | ===== Some elements ===== | ||
| Línea 280: | Línea 289: | ||
| ... | ... | ||
| </code> | </code> | ||
| + | |||
| + | * The url's will end with ''/''. | ||
| ===== Notes ===== | ===== Notes ===== | ||
| Línea 291: | Línea 302: | ||
| return redirect(url_for('static', filename='resume.html')) | return redirect(url_for('static', filename='resume.html')) | ||
| </code> | </code> | ||
| - | ''url_for(folder, file)'' will return the url for that file in that folder. | + | |
| + | ==== url_for ==== | ||
| + | |||
| + | ''url_for(folder, file)'' will return the url for that file in that folder. \\ | ||
| + | |||
| + | For static files: | ||
| + | <code python> | ||
| + | url_for('static', filename='path/to/file') | ||
| + | # In blueprints | ||
| + | url_for('admin.static', filename='style.css') | ||
| + | </code> | ||
| + | You also can use it in templates. | ||
| + | <code> | ||
| + | <link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='bootstrap/bootstrap.min.css') }}"> | ||
| + | </code> | ||
| + | In blueprints: | ||
| + | <code python> | ||
| + | # this blueprint -> printable function | ||
| + | url_for('.printable') | ||
| + | # blueprint: resume, resource FUNCTION: printable_resume | ||
| + | url_for('resume.printable_resume') | ||
| + | </code> | ||
| + | You can get the absolute url: | ||
| + | <code python> | ||
| + | url_for('settings', _external=True) | ||
| + | </code> | ||