Trying to run this simple Flask app, not creating a Flask app directly, but subclassing it instead:
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
import logging
from flask import Flask
class TestFlaskApp(Flask):
def __init__(self):
super(Flask, self).__init__("PyPad")
self._logger = logging.getLogger(self.__class__.__name__)
self.debug = True
self.route('/', defaults={'path': '.'})
self.route('/<path:path>')
def catch_all(path):
return path
app = TestFlaskApp()
app.run()
Throws this error:
Traceback (most recent call last):
File "/tmp/myproject/test.py", line 24, in <module>
app = TestFlaskApp()
File "/tmp/myproject/test.py", line 17, in __init__
self.debug = True
File "/usr/lib/python2.7/dist-packages/flask/config.py", line 36, in __set__
obj.config[self.__name__] = value
AttributeError: 'TestFlaskApp' object has no attribute 'config'
Using:
- Ubuntu 16.04 LTS Xenial
- Python 2.7.11+
- Flask (0.10.1)
Aucun commentaire:
Enregistrer un commentaire