Я новичок в флешке и REST-API / серверных сценариях в целом. Я получаю сообщение об ошибке «ImportError: невозможно импортировать имя« flask_app »» при попытке выполнить run_app.py
Это моя структура каталогов.
my_project
- webapp
- __init__.py
- helpers.py
- c_data.py
- run_app.py
Содержимое каждого файла:
__ __ INIT. Ру
"""This is init module."""
from flask import Flask
from webapp import c_data
# Place where webapp is defined
flask_app = Flask(__name__)
c_data.py
"""This module will serve the api request."""
from app_config import client
from webapp import flask_app
from webapp import helpers
from flask import request, jsonify
# Select the database
db = client.newDB
# Select the collection
collection = db.collection
@flask_app.route("/")
def get_initial_response():
"""Welcome message for the API."""
# Message to the user
message = {
'apiVersion': 'v1.0',
'status': '200',
'message': 'Welcome to the Flask API'
}
# Making the message looks good
resp = jsonify(message)
# Returning the object
return resp
run_app.py
# -*- coding: utf-8 -*-
from webapp import flask_app
if __name__ == '__main__':
# Running webapp in debug mode
flask_app.run(debug=True)
Что я делаю не так?