Answer the question
In order to leave comments, you need to log in
Why doesn't the Flask-MongoEngine tutorial example work?
I started to learn how to use mongoDB with flask, I open the tutorial, copy the code, start the local server and an error appears:
File "C:\venv\flask_secure\lib\site-packages\mongoengine\connection.py", line 124, in get_connection
raise ConnectionError("Cannot connect to database %s :\n%s" % (alias, e))
mongoengine.connection.ConnectionError: Cannot connect to database default :
[WinError 10061] Подключение не установлено, т.к. конечный компьютер отверг запрос на подключение
# Set the path
import os, sys
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
from flask.ext.script import Manager, Server
from tumblelog import app
manager = Manager(app)
# Turn on debugger by default and reloader
manager.add_command("runserver", Server(
use_debugger = True,
use_reloader = True,
host = '0.0.0.0')
)
if __name__ == "__main__":
manager.run()
Answer the question
In order to leave comments, you need to log in
In the code above, there are no settings for MongoDB at all.
And it's better to read in the application documentation https://flask-mongoengine.readthedocs.org/en/latest/
Understood. For a long time I could not guess that it was necessary to install the database itself separately. In the tutorials, this seems to be considered obvious.
In general, in order for mongodb to work locally, you need to download it from the off site and run it on your computer.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question