Multiprocessing in Flask
<p>Probably, this was repeated in a different way.
May I know where am I goin wrong?
Following is the code and the error</p>

<p><strong>CODE:</strong></p>

<pre><code>from flask import Flask, render_template
import thread
from multiprocessing import Process

app = Flask(__name__)

def print_time():
   i = 0
   while 1:
      i += 1

def server():
    @app.route('/')
    def index():
        return 'Index Page'

    @app.route('/hello/')
    def hello(name=None):
        return render_template('index.html', name=i)

if __name__ == '__main__':
    Process(target=server).start()
    Process(target=print_time).start()
</code></pre>

<p><strong>ERROR(PREV):</strong></p>

<pre><code>File "C:\Program Files\Anaconda2\envs\hvc\dashboard.py", line 15
return 'Index Page'
     ^
IndentationError: expected an indented block
</code></pre>

<p><strong>ERROR(NOW):</strong></p>

<pre><code>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>Thank you.</p>

<p>The code mixes tabs and spaces.</p>

<p>These two lines:</p>

<pre><code>    def index():
        return 'Index Page'
</code></pre>

<p>Are actually:</p>

<pre><code>[tab]def index():
    [tab]return 'Index Page'
</code></pre>

<p>When tabs are used in Python source code, they are first replaced with spaces until the first column that is a multiple of 8. That makes the above euivalent to:</p>

<pre><code>        def index():
        return 'Index Page'
</code></pre>

<p>So, the <code>return</code> line is not indented.</p>

<p>The moral of the story is: do not use tabs. Configure the editor to replace tabs with 4 spaces.</p>

python flask multiprocessing