SpecialistOff.NET / Вопросы / Статьи / Фрагменты кода / Резюме / Метки / Помощь / Файлы

Список вопросов Печать

Правила для переменных app.route во Flask


Метки: python flask 

Ответы

RemiZOffAlex  Создано: 2016-09-11 21:51:10.747739  Обновлено: 2016-09-11 21:51:10.747739
@app.route('/user/<username>')
def show_user_profile(username):
    # show the user profile for that user
    return 'User %s' % username

@app.route('/post/<int:post_id>')
def show_post(post_id):
    # show the post with the given id, the id is an integer
    return 'Post %d' % post_id
  • string accepts any text without a slash (the default)
  • int accepts integers
  • float like int but for floating point values
  • path like the default but also accepts slashes
  • any matches one of the items provided
  • uuid accepts UUID strings

Возможно будут интересны и другие вопросы