This is using a template

This Website

I built this website using Bootstap for the front end, and Flask (a python package) for the back end. I started by taking classes on HTML, CSS, Bootstrap, and Jinja2 on Codecademy. I deployed the site using Nginx and Gunicorn on a Linode server.

You can check out the source code below.

This is the main file that handles all of the routing between webpages and sending of emails through the contact page.

  from flask import Flask, render_template, url_for, flash, redirect
  from forms import RegistrationForm
  import smtplib, ssl
  port = 465  # For SSL
  smtp_server = ""
  sender_email = "******************"
  receiver_email = ""
  password = "********"
  app = Flask(__name__)
  app.config['SECRET_KEY'] = '***********'

  def home():
      return render_template('home.html')

  def esra():
      return render_template('esra.html', title = "ESRA Overview")

  def daq():
      return render_template('daq.html', title = "ESRA DAQ Project")

  def watering():
      return render_template('watering.html', title = "Automated Water and Sunlight System")

  def website():
      return render_template('website.html', title = "This Website!")

  def mill():
      return render_template('cnc_mill.html', title = "CNC Mill")

  def woodworking():
      return render_template('woodworking.html', title = "Woodworking")

  def nixie():
      return render_template('nixie.html', title = "Nixie Clock")

  @app.route("/contact",methods=['GET', 'POST'])
  def contact():
      form = RegistrationForm()
      if form.validate_on_submit():
          flash(f'Email sent!','success')
          context = ssl.create_default_context()
          with smtplib.SMTP_SSL(smtp_server, port, context=context) as server:
              server.login(sender_email, password)
              message = "Subject: Website message: " + str( + "\n\n" + str( + "\n\n From: " + str(
              server.sendmail(sender_email, receiver_email, message)
          return redirect(url_for('home'))
      return render_template('contact.html', title='Contact', form=form)

  if __name__ == '__main__':

Page Layout

The layout.html file contains the content that is displayed on every page such as the top navigation bar, tab titles, styling, and notifications.

  <!DOCTYPE html>
  <html lang="en" dir="ltr">
      <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
      <!-- Bootstrap CSS -->
      <link rel="stylesheet" href="" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
      <link rel="stylesheet" type="text/css" href="/static/main.css">
      <script defer src="" integrity="sha384-tzzSw1/Vo+0N5UhStP3bvwWPq+uvzCMfrN1fEFe+xBmv1C/AtVX5K0uZtmcHitFZ" crossorigin="anonymous"></script>
      <script defer src="" integrity="sha384-6OIrr52G08NpOFSZdxxz1xdNSndlD4vdcf/q2myIUVO0VsqaGHJsB0RaBE01VTOY" crossorigin="anonymous"></script>
      {% if title %}
        <title>Cole's Projects - {{title}}</title>
      {%else %}
        <title>Cole's Projects </title>
      {% endif %}
      <nav class="navbar fixed-top navbar-expand-lg navbar-dark bg-dark" id="navbar">
        <a class="navbar-brand" href="/home">Cole's Projects</a>
        <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNavDropdown" aria-controls="navbarNavDropdown" aria-expanded="false" aria-label="Toggle navigation">
          <span class="navbar-toggler-icon"></span>
        <div class="collapse navbar-collapse" id="navbarNavDropdown">
          <ul class="navbar-nav">
            <li class="nav-item dropdown">
              <a class="nav-link dropdown-toggle" href="#" id="navbarDropdownMenuLink" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
              <div class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink">
                <a class="dropdown-item" href="/esra">Project Overview</a>
                <a class="dropdown-item" href="/daq">Data Acquisition System</a>
            <li class="nav-item">
              <a class="nav-link" href="/cnc_mill">CNC Mill</a>
            <li class="nav-item">
              <a class="nav-link" href="/watering">Automated Irrigation</a>
            <li class="nav-item">
              <a class="nav-link" href="/website">Website</a>
            <li class="nav-item">
              <a class="nav-link" href="/static/media/Domenico_Cole_Resume.pdf" target="_blank">Resume</a>
            <li class="nav-item">
              <a class="nav-link" href="">LinkedIn</a>
      <p>This is using a template</p>
      <div class="container">
        {% with messages = get_flashed_messages(with_categories=true) %}
          {% if messages %}
            {% for category, message in messages %}
              <div class="alert alert-{{ category }}" style="margin-top:3em;">
                {{ message }}
            {% endfor %}
          {% endif %}
        {% endwith %}
        {% block content %}{% endblock %}

      <!-- End of row with nav component -->
      <!-- Bootstrap JavaScript Libraries -->
      <script src="" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo"
      <script src="" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49"
      <script src="" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy"

The file handles the user input for the contact page and passes that information to

  from flask_wtf import FlaskForm
  from wtforms import StringField, PasswordField, SubmitField
  from wtforms.validators import DataRequired, Length, Email, EqualTo

  class RegistrationForm(FlaskForm):
      email = StringField('Email',validators=[DataRequired(), Email()])
      confirm_email = StringField('Confirm email',validators=[EqualTo('email')])
      subject = StringField('Subject')
      message = StringField('Message', validators=[DataRequired()])
      submit = SubmitField('Send')

Contact Page

The contact.html page displays the forms, setup in the file, as well as any error messages. Examples of error messages might include an invalid email, emails that do not match, or an empty message box.

  {%extends "layout.html" %}
  {% block content %}
    <div class="content-section" style="margin-top:2em;">
      <form action="" method="post">
        <fieldset class="form-group">
          <legend class="border-bottom mb-4">Contact Me!</legend>
          <div class="form-group">
            {% if %}
              {{"form-control form-control-lg is-invalid")}}
              <div class="invalid-feedback">
                {% for error in %}
                <span> {{ error }} </span>
                {% endfor %}
            {% else %}
              {{"form-control form-control-lg")}}
            {% endif %}
          <div class="form-group">
            {% if form.confirm_email.errors %}
              {{ form.confirm_email(class="form-control form-control-lg is-invalid")}}
              <div class="invalid-feedback">
                {% for error in form.confirm_email.errors %}
                <span> {{ error }} </span>
                {% endfor %}
            {% else %}
              {{form.confirm_email(class="form-control form-control-lg")}}
            {% endif %}
          <div class="form-group">
            {% if form.subject.errors %}
              {{ form.subject(class="form-control form-control-lg is-invalid")}}
              <div class="invalid-feedback">
                {% for error in form.subject.errors %}message
                <span> {{ error }} </span>
                {% endfor %}
            {% else %}
              {{form.subject(class="form-control form-control-lg")}}
            {% endif %}
          <div class="form-group">
            {% if form.message.errors %}
              {{ form.message(class="form-control form-control-lg is-invalid")}}
              <div class="invalid-feedback">
                {% for error in form.message.errors %}
                <span> {{ error }} </span>
                {% endfor %}
            {% else %}
              {{form.message(class="form-control form-control-lg")}}
            {% endif %}
        <div class="form-group">
          {{form.submit(class="btn btn-outline-info")}}
  {% endblock content %}