title: Python Flask Error - The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again
body: <p>I'm relatively new to Flask and I'm trying to get the app to run yet when I run the code in the terminal I get the following message:</p>
  
  <pre><code>404 Not Found 
  The requested URL was not found on the server. If you entered the URL 
  manually please check your spelling and try again.
  </code></pre>
  
  <p>Here is my app.py file:</p>
  
  <pre><code>from flask import Flask
  from flask_mongoengine import MongoEngine
  from flask_sslify import SSLify
  import os
  
  
  app = Flask(__name__)
  app.url_map.strict_slashes = False
  app.config.from_object('config')
  db = MongoEngine(app)
  </code></pre>
  
  <p>Here is my views.py file:</p>
  
  <pre><code>from flask import Flask, request, render_template, flash, redirect, 
  session, url_for, g, jsonify, make_response
  
  
  @app.before_request
  def before_request():
      g.user = current_user
  
  
  @app.errorhandler(404)
  def not_found_error(error):
      return render_template('404.html'), 404
  
  
  @app.errorhandler(500)
  def internal_error(error):
      return render_template('500.html'), 500
  
  
  @app.route('/index', methods=['GET', 'POST'])
  def index():
      if not session.get('user_id'):
          return redirect(url_for('login'))
      user = User.objects.get(id=session.get('user_id'))
      return render_template('frontpage.html', user=user)
  
  @app.route('/')             
  def root():
      return redirect(url_for('index'))
  
  
  if __name__ == "__main__":
      app.run(debug=True)
  </code></pre>
  
  <p>Here is my models.py file:</p>
  
  <pre><code>from flask_mongoengine.wtf import model_form
  from mongoengine import Document, StringField, EmailField, 
  ReferenceField, IntField, DateTimeField, \
  BooleanField, DictField, ListField, EmbeddedDocument, \
  EmbeddedDocumentListField, FloatField, FileField
  
  from flask import request
  from hashlib import md5
  from app import db
  
  class User(Document):
      email = StringField(required=True, unique=True)
      username = StringField(required=True, max_length=50, unique=True)
      password = StringField(required=True)
      aboutme = StringField()
      photo = FileField()
  
      created_at = DateTimeField()
  
      password_reset_token = StringField()
  
      user_type = StringField()  
      is_admin = BooleanField()
      is_logged_in = BooleanField()
  
      def is_active(self):
  
          return True
  
      def get_id(self):
          return self.email
  
      def is_authenticated(self):
          return self.authenticated
  
      def is_anonymous(self):
          return False
  </code></pre>
  
  <p>Here is my base.html</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
    &lt;head&gt;
  
      &lt;title&gt; Hello Everybody! &lt;/title&gt;
  
      &lt;link href="https://cdnjs.cloudflare.com/ajax/libs/twitter- 
  bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" media="screen"&gt;
  &lt;script src="https://code.jquery.com/jquery-latest.js"&gt;&lt;/script&gt;
  &lt;script src="https://cdnjs.cloudflare.com/ajax/libs/twitter- 
  bootstrap/3.3.7/js/bootstrap.min.js"&gt;&lt;/script&gt;
  &lt;script src="{{ url_for('.static', filename='js/moment.min.js') }}"&gt; 
  &lt;/script&gt;
  &lt;script type="text/javascript" 
  src="//cdnjs.cloudflare.com/ajax/libs/socket.io/1.3.6/socket.io.min.js"&gt; 
  &lt;/script&gt;
  &lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&gt;
  &lt;link href="/static/css/main.css" rel="stylesheet"&gt;
  
  &lt;/head&gt;
  
  &lt;body&gt;
  
  &lt;!-- Fixed navbar --&gt;
  &lt;nav class="navbar navbar-default navbar-static-top"&gt;
    &lt;div class="container"&gt;
      &lt;div class="navbar-header"&gt;
        &lt;button type="button" class="navbar-toggle collapsed" data- 
  toggle="collapse" data-target="#navbar" aria-expanded="false" aria- 
  controls="navbar"&gt;
          &lt;span class="sr-only"&gt;Toggle navigation&lt;/span&gt;
          &lt;span class="icon-bar"&gt;&lt;/span&gt;
          &lt;span class="icon-bar"&gt;&lt;/span&gt;
          &lt;span class="icon-bar"&gt;&lt;/span&gt;
        &lt;/button&gt;
        &lt;a class="navbar-brand" href="/index"&gt; Hello &lt;/a&gt;
      &lt;/div&gt;
      &lt;div id="navbar" class="navbar-collapse collapse"&gt;
        &lt;ul class="nav navbar-nav"&gt;
  
        &lt;/ul&gt;
        &lt;ul class="nav navbar-nav navbar-right"&gt;
  
         {% if user is defined %}
  
          &lt;li class="dropdown"&gt;
  
          &lt;a href="#" class="dropdown-toggle" data-toggle="dropdown" 
  role="button" aria-haspopup="true" aria-expanded="false"&gt;{{ user.email 
  }} &lt;span class="caret"&gt;&lt;/span&gt;&lt;/a&gt;
  
            &lt;ul class="dropdown-menu"&gt;
  
  
              &lt;li&gt;&lt;a href="frontpage"&gt;Front Page&lt;/a&gt;&lt;/li&gt;
              &lt;li&gt;&lt;a href="profile"&gt;Edit Profile&lt;/a&gt;&lt;/li&gt;
  
              &lt;li role="separator" class="divider"&gt;&lt;/li&gt;
  
  
              {% if user.is_admin %}
              &lt;li&gt;&lt;a href="invite"&gt;Invite&lt;/a&gt;&lt;/li&gt;
              {% endif %}
              &lt;li&gt;&lt;a href="logout"&gt;Logout&lt;/a&gt;&lt;/li&gt;
            &lt;/ul&gt;
          &lt;/li&gt;
        &lt;/ul&gt;
      &lt;/div&gt;&lt;!--/.nav-collapse --&gt;
    &lt;/div&gt;
  &lt;/nav&gt;
  
  &lt;div class="container"&gt;
  
  
    &lt;div class="row"&gt;
      &lt;div class="span12"&gt;
          {% include 'flash.html' %}
        {% block content %}{% endblock %}
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;  
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>And finally here is my frontpage.html:</p>
  
  <pre><code>{% extends "base.html" %}
  
  {% block content %}
  
  &lt;h6&gt; Welcome to my site! &lt;/h6&gt;
  
  
  {% endblock %}
  </code></pre>
  
  <p>Any and all help would be immensely appreciated!</p>