If you like this site and you like coffee, why not buy me one. Because I love it

Click to buy coffe
avatar
Untitled

Guest 10 22nd Sep, 2022

MARKUP 2.28 KB
                                           
                         from flask import Flask, render_template
from flask_bs4 import Bootstrap
from flask_moment import Moment
from datetime import datetime
from flask_wtf import FlaskForm
from wtforms import StringField, SubmitField
from wtforms.validators import DataRequired

app = Flask(__name__)
bootstrap = Bootstrap(app)
moment = Moment(app)
app.config['SECRET_KEY'] = 'rnbockhkjernc0295'

class NameForm(FlaskForm):
    userName = StringField('Podaj swoje imie: ', validators=[DataRequired()])
    submit = SubmitField('Wyślij!')

@app.route('/')
def index ():
    userForm = NameForm()
    return render_template('index.html', title='Strona główna', userForm=userForm)


@app.route('/user/<name>')
def user(name):
    return render_template('index.html',
                            title = 'Strona glowna', name=name)

if __name__ == '__main__':
        app.run(debug=True)

index:
{% extends "bootstrap/base.html" %}
{%block scripts%}
    {{ super() }}
    {{moment.include_moment()}}
    {{moment.locale('pl')}}
{%endblock%}
{% block title %} {{ title }} {% endblock %}
{% block navbar %}
    {% include "includes/navbar.html" %}
{% endblock %}
{% block content %}
<div class="container">
    <from method = "POST" action="/">
        {{userForm.hidden_tag()}}
        {{userForm.userName.label}}{{userForm.userName()}}
        {{userForm.submit()}}
    </from>
</div>
{% endblock %}


navbar:
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
    <div class="container">
        <a href="/" class="navbar-brand">Home</a>
        <div class="collapse navbar-collapse">
            <ul class="navbar-nav">
                <li class="nav-item">
                    <a href="#" class="nav-link">Menu 1</a>
                </li>
                 <li class="nav-item">
                    <a href="#" class="nav-link">Menu 2</a>
                </li>
            </ul>
        </div>
    </div>
</nav>
                      
                                       
To share this paste please copy this url and send to your friends
RAW Paste Data
Recent Pastes
Ta strona używa plików cookie w celu usprawnienia i ułatwienia dostępu do serwisu oraz prowadzenia danych statystycznych. Dalsze korzystanie z tej witryny oznacza akceptację tego stanu rzeczy.
Wykorzystywanie plików Cookie
Jak wyłączyć cookies?
ROZUMIEM