rekrutacja
from flask import Flask app = Flask(__name__)
@app.route('/') def index(): return "Hello, World!"
if name = "__main__":
app.run()
<title>{% block title %}{% endblock %}</title>
<ul>
{% for user in users %}
<li><a href="{{ user.url }}">
{{ user.username }}
</a></li>
{% endfor %}
</ul>
class Person(models.Model):
first_name = models.CharField(max_length=30)
last_name = models.CharField(max_length=30)
from sqlalchemy import Column, Integer, String
class Person(Base):
__tablename__ = 'persons'
id = Column(Integer, primary_key=True)
first_name = Column(String(30))
last_name = Column(String(30))
from sqlalchemy.sql import extract
entries_a_month = Entry.query.filter(
(extract(Entry.pub_date, 'year') == 2011) &
(extract(Entry.pub_date, 'month') == 1)
).all()
from django.conf.urls import patterns, url
urlpatterns = patterns('',
url(r'^articles/(\d{4})/$', 'news.views.year_archive'),
url(r'^articles/(\d{4})/(\d{2})/$',
'news.views.month_archive'),
url(r'^articles/(\d{4})/(\d{2})/(\d+)/$',
'news.views.article_detail'),
)
from flask import request
@app.route('/todo/api/v1.0/tasks', methods = ['POST'])
def create_task():
if not request.json or not 'title' in request.json:
abort(400)
task = {
'id': tasks[-1]['id'] + 1,
'title': request.json['title'],
'description': request.json.get('description', ""),
'done': False
}
tasks.append(task)
return jsonify( { 'task': task } ), 201
Django:
Flask: