我的文件结构如下:
.
├── AirQualityVisualzationApp
│ ├──./static
│ ├──./templates
| ├──./air_quality_api.py
│ ├── ./app.py
├── ./nltk.txt
│
├── ./Procfile
│
├── ./requirements.txt
│
├── ./run.sh
│
├── ./runtime.txt
即使我的air_quality_api.py明确存在,也给我错误:
from air_quality_api import get_aqi
2019-08-03T06:21:48.084410+00:00 app[web.1]: ModuleNotFoundError: No module named 'air_quality_api'
在我的Procfile中,
web: gunicorn AirQualityVisualizationApp.app:app
由于应用程序位于AirQaulityVisualizationApp文件夹中的app.py中。内部存在air_quality_api.py get_aqi函数
在我的app.py中,它看起来像这样:
from flask import Flask, jsonify, request, redirect, render_template
from flask_apscheduler import APScheduler
from flask_sqlalchemy import SQLAlchemy
import json
import os
import pandas as pd
import pymysql
import sqlalchemy
from sqlalchemy.ext.automap import automap_base
from sqlalchemy.orm import Session
from sqlalchemy import create_engine, func
import time
#my dependencies
from air_quality_api import get_aqi
from summarize_text import *
app = Flask(__name__)
scheduler = APScheduler()
scheduler.init_app(app)
scheduler.start()
# ---------------------------------- Database setup -------------------------------- #
# setting up which database I will use
app.config["SQLALCHEMY_DATABASE_URI"] = os.environ.get('DATABASE_URL', '') or 'mysql://root:Gksmf12#@localhost:3306/aqi_db'
app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False
# # Creating database instance
db = SQLAlchemy(app)
@app.route("/")
def index():
"""Return the homepage."""
return render_template("index.html")
有人可以帮忙吗?我已经尝试解决了一段时间,找不到任何有用的东西。