0
Der Versuch, diese einfache Flask App zu laufen, nicht eine Flasche App direkt erstellen, aber Subklassen es statt:Subclassing Flask Anwendung läuft nicht
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
import logging
from flask import Flask
class TestFlaskApp(Flask):
def __init__(self):
super(Flask, self).__init__("TestApp")
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()
Wirft diesen Fehler:
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'
verwenden:
- Ubuntu 16.04 LTS Xenial
- Python 2.7.11+
- Flask (0.10.1)
Ich bin so froh, dass Python3 Sie die Möglichkeit, 'super einfach zu schreiben gibt() parentmethod (* args, ** kwargs)', weil ich nie die Argumente 'super()' erinnern kann.: P –