Krishnang K Dalal Krishnang K Dalal - 1 year ago 151
Python Question

Python Flask not rendering template

I have a simple trial code for building a web page using Python Flask but somehow it is not working. The code is as following:

from flask import Flask, request, render_template
from square import Square

app = Flask(__name__)

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

if __name__ == '__main__':


<!doctype html>
<h1>Hello Wold!</h1>
<h2>Welcome Here</h2>

when I run the from the Spyder console and go on to Google Chrome and enter
, Chrome doesn't load the page.

When I run using windows command promt, it throws following error:

* Running on (Press CTRL+C to quit)
* Restarting with stat
* Debugger is active!
* Debugger pin code: 294-294-951
Exception in thread Thread-1:
Traceback (most recent call last):
File "C:\Users\kdalal\AppData\Local\Continuum\Anaconda3\lib\", line 916, in _bootstrap_inner
File "C:\Users\kdalal\AppData\Local\Continuum\Anaconda3\lib\", line 864, in run self._target(*self._args, **self._kwargs)
File "C:\Users\kdalal\AppData\Local\Continuum\Anaconda3\lib\site-packages\werkzeug\", line 670, in inner fd=fd)
File "C:\Users\kdalal\AppData\Local\Continuum\Anaconda3\lib\site-packages\werkzeug\", line 564, in make_server passthrough_errors, ssl_context, fd=fd)
File "C:\Users\kdalal\AppData\Local\Continuum\Anaconda3\lib\site-packages\werkzeug\", line 474, in __init__ socket.SOCK_STREAM)
File "C:\Users\kdalal\AppData\Local\Continuum\Anaconda3\lib\", line 460, in fromfd nfd = dup(fd)
OSError: [WinError 10038] An operation was attempted on something that is not a socket

Please suggest me what is an issue here. Thank you.

P.S: My 'first_page.html' is under templates folder

Answer Source

This issue was fixed in Flask 0.12.1 (werkzeug 0.12.1, to be more precise).

Use the latest version, you'll be fine.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download