so I've been following this tutorial on how to build an basic Flask website off youtube Tutorial. Currently trying to add HTML templates which are giving me "500 Internal Server Error" with application errors in the CMD.
**My python code
**`
from flask import Flask, redirect, url_for, render_template
app = Flask(__name__)
#app.route("/<name>")
def home(name):
return render_template("index.html", content=name)
if __name__ == "__main__":
app.run()
**my html code **
<!DOCTYPE html>
<html>
<head>
<title>ETF World!</title>
</head>
<body>
<h1>Explore the world of Exchange Traded Funds</h1>
<p>{{content}}</p>
</body>
</html>
The ERROR
Traceback (most recent call last):
File "C:\Users\Bradley J Stewart\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\flask\app.py", line 2077, in wsgi_app
response = self.full_dispatch_request()
File "C:\Users\Bradley J Stewart\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\flask\app.py", line 1525, in full_dispatch_request
rv = self.handle_user_exception(e)
File "C:\Users\Bradley J Stewart\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\flask\app.py", line 1523, in full_dispatch_request
rv = self.dispatch_request()
File "C:\Users\Bradley J Stewart\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\flask\app.py", line 1509, in dispatch_request
return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)
TypeError: home() missing 1 required positional argument: 'name'
I expected the website to work when I enter a forward slash in the URL and for dynamic information to pass information to be delivered from the backend to the front of what "content" variable I wrote. Not 100% sure if the video is relevant anymore as it is 3 years old
Any help is deeply appreciated.
it happens to work on mine though.
main.py
from flask import Flask, redirect, url_for, render_template
app = Flask(__name__)
#app.route("/<name>")
def home(name):
return render_template("index.html", content=name)
if __name__ == "__main__":
app.run()
index.html:
<head>
<title>ETF World!</title>
</head>
<body>
<h1>Explore the world of Exchange Traded Funds</h1>
<p>{{content}}</p>
</body>
</html>
also make sure to put index.html to the template folder because flask look into that folder.
Related
I'm new to Flask and while following some youtube tutorials for Flask-Admin, I came across the fact that we need to create the admin panel by extending the template in "admin/index.html"
The instructor said that the 'admin/master.html' is an implicit file and we don't need to create it but do need to extend it.
But I'm getting a error message that says that the template "admin/master.html" couldn't be found.
How do I work this problem out?
This is the error log
[2023-01-05 23:13:42,958] ERROR in app: Exception on /admin/ [GET]
Traceback (most recent call last):
File "/SSD_Data/DevFile/AayushPokharel/env/lib/python3.10/site-packages/flask/app.py", line 2525, in wsgi_app
response = self.full_dispatch_request()
File "/SSD_Data/DevFile/AayushPokharel/env/lib/python3.10/site-packages/flask/app.py", line 1822, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/SSD_Data/DevFile/AayushPokharel/env/lib/python3.10/site-packages/flask/app.py", line 1820, in full_dispatch_request
rv = self.dispatch_request()
File "/SSD_Data/DevFile/AayushPokharel/env/lib/python3.10/site-packages/flask/app.py", line 1796, in dispatch_request
return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
File "/SSD_Data/DevFile/AayushPokharel/app/admin/routes.py", line 7, in adminRoute
return render_template("admin/index.html")
File "/SSD_Data/DevFile/AayushPokharel/env/lib/python3.10/site-packages/flask/templating.py", line 147, in render_template
return _render(app, template, context)
File "/SSD_Data/DevFile/AayushPokharel/env/lib/python3.10/site-packages/flask/templating.py", line 130, in _render
rv = template.render(context)
File "/SSD_Data/DevFile/AayushPokharel/env/lib/python3.10/site-packages/jinja2/environment.py", line 1301, in render
self.environment.handle_exception()
File "/SSD_Data/DevFile/AayushPokharel/env/lib/python3.10/site-packages/jinja2/environment.py", line 936, in handle_exception
raise rewrite_traceback_stack(source=source)
File "/SSD_Data/DevFile/AayushPokharel/app/templates/admin/index.html", line 1, in top-level template code
{% extends 'admin/master.html' %} {% block body %}
File "/SSD_Data/DevFile/AayushPokharel/env/lib/python3.10/site-packages/flask/templating.py", line 62, in get_source
return self._get_source_fast(environment, template)
File "/SSD_Data/DevFile/AayushPokharel/env/lib/python3.10/site-packages/flask/templating.py", line 98, in _get_source_fast
raise TemplateNotFound(template)
jinja2.exceptions.TemplateNotFound: admin/master.html
127.0.0.1 - - [05/Jan/2023 23:13:42] "GET /admin/ HTTP/1.1" 500 -
This is my admin template
<!--app/templates/admin/index.html-->
{% extends 'admin/master.html' %} {% block body %}
<p>This is Admin Page</p>
{% endblock %}
my admin init blueprint
# app/admin/__init__.py
from flask import Blueprint
from flask_admin.contrib.sqla import ModelView
from app.extensions import admin, db
from app.models.user import User
bp = Blueprint("admin", __name__)
admin.add_view(ModelView(User, db.session))
from app.admin import routes
my admin routes
# app/admin/routes.py
from flask import render_template
from app.admin import bp
#bp.route("/")
def adminRoute():
return render_template("admin/index.html")
my main app file
# app/__init__.py
# Regular Imports
from flask import Flask
# Config Import
from config import Config
# Extensions' Imports
from app.extensions import db
from app.extensions import login_manager
# Blueprints' Imports
from app.main import bp as main_bp
from app.admin import bp as admin_bp
def create_app(config_class=Config):
app = Flask(__name__)
app.config.from_object(config_class)
# Initialize Flask extensions here
db.init_app(app)
login_manager.init_app(app)
# Register blueprints here
app.register_blueprint(main_bp)
app.register_blueprint(admin_bp, url_prefix="/admin")
# Returning created App Instance
return app
I have been really stumped on this, been out of this game of web dev/python for a bit. I had a previously working Azure app service running this website, we did a minor HTML spelling change and re deployed. I am assuming some dependency got updated and now its broken. I don't know if this is a packaging version issue or if I have a missing import for my flask app.
I am getting a NameError: name 'Markup' is not defined error when trying to load a static html page. My app starts up just fine but I can't load the actual web pages.
Full Traceback
Traceback (most recent call last):
File "C:\Users\St**\PythonProjects\**Site-Portfolio\lib\site-packages\flask\app.py", line 2095, in __call__
return self.wsgi_app(environ, start_response)
File "C:\Users\St**\PythonProjects\**Site-Portfolio\lib\site-packages\flask\app.py", line 2080, in wsgi_app
response = self.handle_exception(e)
File "C:\Users\St**\PythonProjects\**Site-Portfolio\lib\site-packages\flask_cors\extension.py", line 165, in wrapped_function
return cors_after_request(app.make_response(f(*args, **kwargs)))
File "C:\Users\St**\PythonProjects\**Site-Portfolio\lib\site-packages\flask\app.py", line 2077, in wsgi_app
response = self.full_dispatch_request()
File "C:\Users\St**\PythonProjects\**Site-Portfolio\lib\site-packages\flask\app.py", line 1525, in full_dispatch_request
rv = self.handle_user_exception(e)
File "C:\Users\St**\PythonProjects\**Site-Portfolio\lib\site-packages\flask_cors\extension.py", line 165, in wrapped_function
return cors_after_request(app.make_response(f(*args, **kwargs)))
File "C:\Users\St**\PythonProjects\**Site-Portfolio\lib\site-packages\flask\app.py", line 1523, in full_dispatch_request
rv = self.dispatch_request()
File "C:\Users\St**\PythonProjects\**Site-Portfolio\lib\site-packages\flask\app.py", line 1509, in dispatch_request
return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)
File "C:\Users\St**\PycharmProjects\**Site-portfolio\application.py", line 32, in index
return render_template("//index.html")
File "C:\Users\St**\PythonProjects\**Site-Portfolio\lib\site-packages\flask\templating.py", line 147, in render_template
ctx.app.update_template_context(context)
File "C:\Users\St**\PythonProjects\**Site-Portfolio\lib\site-packages\flask\app.py", line 756, in update_template_context
context.update(func())
File "C:\Users\St**\PythonProjects\**Site-Portfolio\lib\site-packages\flask_recaptcha.py", line 59, in get_code
return dict(recaptcha=Markup(self.get_code()))
NameError: name 'Markup' is not defined
127.0.0.1 - - [08/Apr/2022 17:02:51] "GET /?__debugger__=yes&cmd=resource&f=style.css HTTP/1.1" 304 -
127.0.0.1 - - [08/Apr/2022 17:02:51] "GET /?__debugger__=yes&cmd=resource&f=debugger.js HTTP/1.1" 304 -
127.0.0.1 - - [08/Apr/2022 17:02:51] "GET /?__debugger__=yes&cmd=resource&f=console.png HTTP/1.1" 304 -
Process finished with exit code 0
Here is my code:
from flask import Flask, request, render_template, flash
from flask_mail import Mail, Message
from flask_cors import CORS, cross_origin
from flask_recaptcha import ReCaptcha
import requests
import json
import os
app = Flask(__name__, static_folder='static', static_url_path='')
recaptcha = ReCaptcha(app=app)
app.config['RECAPTCHA_ENABLED'] = True
app.config['RECAPTCHA_PUBLIC_KEY'] = '***********************'
app.config['RECAPTCHA_PRIVATE_KEY'] = '****************************'
#app.route('/', methods=['GET'])
def index():
return render_template("//index.html")
#app.route('/contact-us', methods=['GET'])
#app.route('/contact', methods=['GET', 'POST'])
def contact():
if request.method == 'POST':
r = requests.post('https://www.google.com/recaptcha/api/siteverify',
data={'secret': '***********',
'response': request.form['g-recaptcha-response']})
google_response = json.loads(r.text)
if google_response['success']:
contact_form = {'name': request.form['name'],
'email': request.form['email'],
'message': request.form['message']}
msg = Message(subject='Contact from website',
sender=contact_form['email'],
recipients=['*************'],
body=contact_form['message'])
mail.send(msg)
flash('Success, we will respond within at least 24 hours.')
return render_template('contact.html')
else:
flash('failed to submit, please retry or contact us at ************')
return render_template('contact.html')
return render_template('contact.html')
if __name__ == '__main__':
app.run()
My requirements.txt for package version
Flask>=1.0.2
jinja2>=2.11.3
Flask-Mail>=0.9.1
Flask-Cors>=3.0.9
Flask-Admin>=1.5.2
Flask-ReCaptcha>=0.4.2
Flask-SQLAlchemy>=2.3.2
Flask-WTF>=0.14.2
SQLAlchemy>=1.3.0
requests>=2.20.0
Flask-Login>=0.4.1
Werkzeug>=0.15.3
Flask-ReCaptcha is a very old project. The last update of Flask-ReCaptcha is on 2016. You'd better not use it.
Back to the error log itself, Flask-ReCaptcha has code like from jinja2 import Markup. But, since jinja2==3.1.0, Markup's position has changed. Try pip install jinja2==3.0.0`.
You will probably meet other problems as Flask-ReCaptcha is really old.
Go to Python installation folder
Go to Lib > site-packages
Open flask_recaptcha.py
You'll see something like this:
try:
from flask import request
from jinja2 import Markup
import requests
except ImportError as ex:
print("Missing dependencies")
Change it to:
try:
from flask import request
from markupsafe import Markup
import requests
except ImportError as ex:
print("Missing dependencies")
I am using flask, here giving example, what I want to do. I copied code from flask portal.
from flask import Flask
app = Flask(__name__)
#app.route('/')
def hello_world():
return 'Hello, World!'
Running the app
(py35) root#localhost:tmp root$ flask run
* Serving Flask app "hello"
* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
Send request
root#localhost:~ root$ curl http://localhost:5000/
Hello, World!
I modify my function and change it to raise error.
#app.route('/')
def hello_world():
print(xyz)
return 'Hello, World!'
When i try to send request, it failed
[2017-11-06 10:22:13,625] ERROR in app: Exception on / [GET]
Traceback (most recent call last):
File "/py35/lib/python3.5/site-packages/flask/app.py", line 1982, in wsgi_app
response = self.full_dispatch_request()
File "/py35/lib/python3.5/site-packages/flask/app.py", line 1614, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/py35/lib/python3.5/site-packages/flask/app.py", line 1517, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/Users/nile2691/sbdev/StorageCenterUI/.tox/py35/lib/python3.5/site-packages/flask/_compat.py", line 33, in reraise
raise value
File "/py35/lib/python3.5/site-packages/flask/app.py", line 1612, in full_dispatch_request
rv = self.dispatch_request()
File "py35/lib/python3.5/site-packages/flask/app.py", line 1598, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/private/tmp/hello.py", line 6, in hello_world
print(xyz)
NameError: name 'xyz' is not defined
I have can add try...except in my code, but in real code, its in many place, and I dont want to handle this general exception everywhere.
Is there any way like
try:
process_flask_request()
except Exception as ex:
# Log detail exception
logger.exception(ex)
return "Custome error message for all general exception"
With this changes, instead of getting general error like below
curl http://localhost:5000/
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<title>500 Internal Server Error</title>
<h1>Internal Server Error</h1>
<p>The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.</p>
I want to return proper output, with custom error message.
You can include error handlers like this, e.g. for displaying the internal server error in your example more nicely:
import traceback
(...some code...)
#app.errorhandler(500)
def internal_error(e):
"""
handle internal errors nicely
"""
tb = traceback.format_exc()
return render_template('error.html',
error=e.message,
traceback=tb), 500
In your template you can then output the short error message, and (maybe depending on user rights if you have user management) the detailed stacktrace.
As mentioned in the comments on your question, you should read the documentation to get the full picture.
I am creating a simple app in Python 3.5.2 that authenticates users via Active Directory and applies additional rules based on a user's group membership. The app can successfully authenticate users using the win32security package, and tries to obtain group membership info using pyad.
My problem: I get a pywintypes.com_error message when running the code on my Flask app, preventing me from getting group membership info.
When I run the backend code separately on an iPython console, it works fine. I am able to query group membership. However, when it is part of a Flask app, an error pops out. I have isolated the problem to this part of the code (DN information masked):
group = adgroup.ADGroup.from_dn('CN=someCN,OU=someOU1,OU=someOU2,
DC=test,DC=domain,DC=com,DC=somecountry')
group_members = sum([member.get_attribute("sAMAccountName")
for member in group.get_members()],[])
Has anyone encountered this before? I cannot think of why the code won't run in Flask (though I have just started learning Flask) but it will run in the console.
Code Reference:
I have 3 Python files for my Flask app and an html file in the templates folder.
run.py
from app import app
import os
app.secret_key = os.urandom(16)
app.run(debug=True)
init.py
from flask import Flask
app = Flask(__name__)
from app import views
views.py
from app import app
from flask import Flask, flash, render_template, request, session
import win32security as win32
from pyad import adgroup
#app.route("/")
def home():
if not session.get("logged_in"):
return render_template("login.html")
else:
return "You are currently logged in."
#app.route("/login", methods=["GET","POST"])
def login():
#initialize variables
username = request.form["username"]
password = request.form["password"]
DOMAIN = "test.domain.com.somecountry"
error = None
group = adgroup.ADGroup.from_dn('CN=someCN,OU=someOU1,OU=someOU2,DC=test,DC=domain,DC=com,DC=somecountry')
group_members = sum([member.get_attribute("sAMAccountName") for member in group.get_members()],[])
if username in group_members:
try:
token = win32.LogonUser(username, DOMAIN, password,
win32.LOGON32_LOGON_NETWORK,
win32.LOGON32_PROVIDER_DEFAULT)
is_auth = bool(token)
if is_auth:
session["logged_in"] = True
except:
error = "Incorrect credentials. Please try again."
else:
error = "You are not permitted to access this."
return render_template("login.html", error=error)
login.html
<!doctype html>
<title>Login Test</title>
{% block body %}
{% if session["logged_in"] %}
<p>You are currently logged in.</p>
{% else %}
<form action="/login" method="POST">
<input type="username" name="username" placeholder="Username">
<input type="password" name="password" placeholder="Password">
<input type="submit" value="Log In">
</form>
<li>{{error}}</li>
{% endif %}
{% endblock %}
This is the error traceback:
Traceback (most recent call last):
File "C:\Users\user\AppData\Local\Continuum\Anaconda3\lib\site-packages\flask\app.py", line 2000, in __call__
return self.wsgi_app(environ, start_response)
File "C:\Users\user\AppData\Local\Continuum\Anaconda3\lib\site-packages\flask\app.py", line 1991, in wsgi_app
response = self.make_response(self.handle_exception(e))
File "C:\Users\user\AppData\Local\Continuum\Anaconda3\lib\site-packages\flask\app.py", line 1567, in handle_exception
reraise(exc_type, exc_value, tb)
File "C:\Users\user\AppData\Local\Continuum\Anaconda3\lib\site-packages\flask\_compat.py", line 33, in reraise
raise value
File "C:\Users\user\AppData\Local\Continuum\Anaconda3\lib\site-packages\flask\app.py", line 1988, in wsgi_app
response = self.full_dispatch_request()
File "C:\Users\user\AppData\Local\Continuum\Anaconda3\lib\site-packages\flask\app.py", line 1641, in full_dispatch_request
rv = self.handle_user_exception(e)
File "C:\Users\user\AppData\Local\Continuum\Anaconda3\lib\site-packages\flask\app.py", line 1544, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "C:\Users\user\AppData\Local\Continuum\Anaconda3\lib\site-packages\flask\_compat.py", line 33, in reraise
raise value
File "C:\Users\user\AppData\Local\Continuum\Anaconda3\lib\site-packages\flask\app.py", line 1639, in full_dispatch_request
rv = self.dispatch_request()
File "C:\Users\user\AppData\Local\Continuum\Anaconda3\lib\site-packages\flask\app.py", line 1625, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "C:\Users\user\Documents\test\app\views.py", line 23, in login
group = adgroup.ADGroup.from_dn('CN=someCN,OU=someOU1,OU=someOU2,DC=test,DC=domain,DC=com,DC=somecountry')
File "C:\Users\user\AppData\Local\Continuum\Anaconda3\lib\site-packages\pyad\adobject.py", line 131, in from_dn
return cls(distinguished_name, None, options)
File "C:\Users\user\AppData\Local\Continuum\Anaconda3\lib\site-packages\pyad\adobject.py", line 88, in __init__
self.__set_adsi_obj()
File "C:\Users\user\AppData\Local\Continuum\Anaconda3\lib\site-packages\pyad\adobject.py", line 76, in __set_adsi_obj
self._ldap_adsi_obj = self.adsi_provider.getObject('', self.__ads_path)
File "<COMObject ADsNameSpaces>", line 2, in getObject
pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, None, None, None, 0, -2147221020), None)
I was able to mitigate this error by running my same code in a python2 32bit environment.
Not sure if this is an option, but worth a shot.
I'm new to Flask and I'm trying to learn how to use it. I have a base knowledge of HTML and CSS (enough to make simple pages, not something really fancy).
So, I decided to give Flask a shot, it looks fairly simple to setup at least the basics.
For the moment I'm trying to run a local server (I'm using Windows 7,Python 3.4). Based on some instructions, I set up the project like this:
-Flask (main folder)
routes.py
/templates
template.html
home.html
welcome.html
/static
/css
/img
/js
/font (for the moment the static folder is empty, except the subfolders)
This is the structure of template.html:
<!--DOCTYPE html -->
<html>
<head>
<title>
My first Flask App
</title>
</head>
<body>
<div>
{% block content %}
{% endblock %}
</div>
</body>
</html>
home.html:
{% extends "template.html" %}
{% block content %}
<div>
<h2>Welcome to Flask!</h2>
<br />
<p>Click hereto go to the welcome page</p>
</div>
{% endblock %}
And finally, welcome.html:
{% extends "template.html" %}
{% block content %}
<h2>Sample</h2>
<p>What a nice page</p>
<p>Really nice</p>
{% endblock %}
This is the code in routes.py:
from flask import Flask,render_template
app=Flask(__name__)
#app.route('/')
def home():
return render_template('home.html')
#app.route('/welcome')
def welcome():
return render_template('welcome.html')
if __name__=='__main__':
app.run()
When I try to run the script, the terminal says:
* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
But, when I try to go to localhost:5000 on the browser, I got:
Internal Server Error
The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.
More specifically, on the terminal says this:
127.0.0.1 - - [30/Jan/2016 14:45:51] "GET / HTTP/1.1" 500 -
I know a little about HTTP status code, so I know that code 500 is raised when there is some sort of error. Indeed, when i looked up for information about this problem, every page I found (included here on stackoverflow) suggests that there is some error, either in "routes.py" or in the html pages provided.
Just to be sure, I tried to run this script:
from flask import Flask
app=Flask(__name__)
#app.route('/')
def home():
return '''
<html>
<head>
<title>
My first Flask App
</title>
</head>
<body>
<div>
hello there!
</div>
</body>
</html>
'''
if __name__=='__main__':
app.run()
And this works fine, the server is booted and if I go to localhost:5000 I can see the page correctly. Indeed, on the terminal I see the status code 200, that means "all is ok", if I recall correctly.
I even tried to add more routes, by defining more functions that return the html pages as strings, and all works fine.
I even tried on those pages to use CSS, in the three forms (in line declaration, internal style sheet and external style sheet), it all works as expected.
So, for the last try, i run the original routes.py once again, this time with app.debug=True
This is the traceback that i got:
* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
* Restarting with stat
Traceback (most recent call last):
File "C:\Users\Admin\pyproj\flask\routes.py", line 25, in <module>
app.run()
File "C:\Python34\Lib\site-packages\Flask-0.10.1-py3.4.egg\flask\app.py", line 777, in run
run_simple(host, port, self, **options)
File "C:\Python34\Lib\site-packages\werkzeug-0.11.3-py3.4.egg\werkzeug\serving.py", line 690, in run_simple
reloader_type)
File "C:\Python34\Lib\site-packages\werkzeug-0.11.3-py3.4.egg\werkzeug\_reloader.py", line 252, in run_with_reloader
sys.exit(reloader.restart_with_reloader())
builtins.SystemExit: 0
Seriously, there must be something really obvious that I'm missing here: I checked all the codes countless times. To me, all seems fine: all the tags in the HTML documents are properly closed, the {%---%} syntax for the templates seems good written, the code on routes.py seems correct also. Furthermore, it generally seems that Flask is working, because if I try to return the html pages as strings written direcly in routes.py I can see and interact with the pages. What's going on?
EDIT
Based on davidism suggestion, I tried to run the script with app.run(debug=True,use_reloader=False)
And this is the traceback
Traceback (most recent call last):
File "C:\Python34\lib\site-packages\flask-0.10.1-py3.4.egg\flask\app.py", line 1836, in __call__
return self.wsgi_app(environ, start_response)
File "C:\Python34\lib\site-packages\flask-0.10.1-py3.4.egg\flask\app.py", line 1820, in wsgi_app
response = self.make_response(self.handle_exception(e))
File "C:\Python34\lib\site-packages\flask-0.10.1-py3.4.egg\flask\app.py", line 1403, in handle_exception
reraise(exc_type, exc_value, tb)
File "C:\Python34\lib\site-packages\flask-0.10.1-py3.4.egg\flask\_compat.py", line 33, in reraise
raise value
File "C:\Python34\lib\site-packages\flask-0.10.1-py3.4.egg\flask\app.py", line 1817, in wsgi_app
response = self.full_dispatch_request()
File "C:\Python34\lib\site-packages\flask-0.10.1-py3.4.egg\flask\app.py", line 1477, in full_dispatch_request
rv = self.handle_user_exception(e)
File "C:\Python34\lib\site-packages\flask-0.10.1-py3.4.egg\flask\app.py", line 1381, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "C:\Python34\lib\site-packages\flask-0.10.1-py3.4.egg\flask\_compat.py", line 33, in reraise
raise value
File "C:\Python34\lib\site-packages\flask-0.10.1-py3.4.egg\flask\app.py", line 1475, in full_dispatch_request
rv = self.dispatch_request()
File "C:\Python34\lib\site-packages\flask-0.10.1-py3.4.egg\flask\app.py", line 1461, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "x-wingide-python-shell://70495568/2", line 16, in home
File "C:\Python34\lib\site-packages\flask-0.10.1-py3.4.egg\flask\templating.py", line 127, in render_template
return _render(ctx.app.jinja_env.get_or_select_template(template_name_or_list),
File "C:\Python34\lib\site-packages\jinja2-2.8-py3.4.egg\jinja2\environment.py", line 851, in get_or_select_template
return self.get_template(template_name_or_list, parent, globals)
File "C:\Python34\lib\site-packages\jinja2-2.8-py3.4.egg\jinja2\environment.py", line 812, in get_template
return self._load_template(name, self.make_globals(globals))
File "C:\Python34\lib\site-packages\jinja2-2.8-py3.4.egg\jinja2\environment.py", line 774, in _load_template
cache_key = self.loader.get_source(self, name)[1]
File "C:\Python34\lib\site-packages\flask-0.10.1-py3.4.egg\flask\templating.py", line 64, in get_source
raise TemplateNotFound(template)
I can see the traceback on the browser aswell.
EDIT 2:
Thanks to davidism, I tried to run the script from the command line and it works perfectly. Normally I use WingIDE for writing python code, debugging and so on; but in this particular case it seems to conflict with Jinja2. Indeed, I tested several times now, and every time I use WingIDE I get the 500 status code, when I run the script from the command line (even if I simply double-click on the script) it works fine.