Flask: NameError: 'app' is not defined?
<p>My Flask application has been running fine for the last 24 hours, however I just took it offline to work on it and i'm trying to start it up again and i'm getting this error:</p>

<pre><code>Traceback (most recent call last):
  File "runserver.py", line 1, in &lt;module&gt;
    from app import app
  File "/home/MY NAME/APP FOLDER NAME/app.py", line 15, in &lt;module&gt;
    from Views import *
  File "/home/MY NAME/APP FOLDER NAME/Views.py", line 1, in &lt;module&gt;
    @app.route('/contact', methods=('GET', 'POST'))
NameError: name 'app' is not defined
</code></pre>

<p>I am running the application currently by calling <code>python runserver.py</code></p>

<p><strong>runserver.py:</strong></p>

<pre><code>from app import app

app.run(threaded = True, debug=True, host='0.0.0.0')
</code></pre>

<p><strong>Views.py</strong>: contains all of my routes, I won't post them all, as the error is coming from the first time <code>app</code> is mentioned in this file.</p>

<pre><code>@app.route('/contact', methods=('GET', 'POST'))
def contact():
    form = ContactForm()

    if request.method == 'POST':
        msg = Message("CENSORED,
            sender='CENSORED',
            recipients=['CENSORED'])
        msg.body = """
            From: %s &lt;%s&gt;,
            %s
            """ % (form.name.data, form.email.data, form.message.data)
        mail.send(msg)
        return "&gt;&lt;p&gt;&lt;br&gt;Successfully  sent message!&lt;/p&gt;&lt;/body&gt;"
    elif request.method == 'GET':
        return render_template('contact.html', form=form)
</code></pre>

<p><strong>app.py:</strong> Here is the top of my app.py file, where I define <code>app = Flask(__name__)</code> as well as import my statements.</p>

<pre><code>from flask import Flask, request, render_template, redirect, url_for, send_file
from geopy.geocoders import Bing
from geopy.exc import GeocoderTimedOut
import re
import urllib
from bs4 import BeautifulSoup
from openpyxl import load_workbook
from openpyxl.styles import Style, Font
import os
import pandas as pd
import numpy as np
import datetime
from Helper_File import *
from Lists import *
from Views import *
from flask_mail import Mail, Message
from forms import ContactForm

global today

geolocator = Bing('Censored')

app = Flask(__name__)
</code></pre>

<p><strong>EDIT: I have made the changes suggested in the answer below, but am getting this when I access the page:</strong></p>

<blockquote>
  <p>Not Found</p>
  
  <p>The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.</p>
</blockquote>

<p>Here is my file structure:</p>

<pre><code>DHLSoftware.com
|-static
    |-style.css
|-templates
    |- seperate html file for each page template
|-app.py
|-forms.py
|-helper_file.py
|-Lists.py
|-runserver.py
|-Views.py
</code></pre>

<p>In <code>app.py</code> you should remove the <code>from Views import *</code>. Instead in your <code>Views.py</code> you need to have <code>from app import app</code></p>

<p>That will bring app into the views namespace and I believe that should work for you.</p>

python flask