Я пытаюсь развернуть свое первое веб-приложение flask через Heroku. Но когда я обращаюсь к своему приложению go, оно всегда показывает «Не найден - запрошенный URL-адрес не найден на сервере».
Я пробовал другие маршруты, такие как / register, но все они показывают страницу «Не найдено». Он хорошо работает в моей IDE cloud9 и успешно развертывается на Heroku.
Так в чем проблема? Заранее спасибо!
(я следую этой инструкции: http://cdn.cs50.net/cscip14300/2017/seminars/from_harvard_to_heroku/from_harvard_to_heroku.pdf)
Вот мой журнал:
2020-05-08T16:14:07.000000+00:00 app[api]: Build started by user eungang3@naver.com
2020-05-08T16:14:31.901041+00:00 heroku[web.1]: Restarting
2020-05-08T16:14:31.914350+00:00 heroku[web.1]: State changed from up to starting
2020-05-08T16:14:30.785786+00:00 app[api]: Deploy 0a1a17fe by user eungang3@naver.com
2020-05-08T16:14:30.785786+00:00 app[api]: Release v22 created by user eungang3@naver.com
2020-05-08T16:14:37.844256+00:00 app[web.1]: * Serving Flask app "application" (lazy loading)
2020-05-08T16:14:37.844285+00:00 app[web.1]: * Environment: production
2020-05-08T16:14:37.844361+00:00 app[web.1]: WARNING: This is a development server. Do not use it in a production deployment.
2020-05-08T16:14:37.844446+00:00 app[web.1]: Use a production WSGI server instead.
2020-05-08T16:14:37.844479+00:00 app[web.1]: * Debug mode: on
2020-05-08T16:14:37.863075+00:00 app[web.1]: INFO:werkzeug: * Running on http://0.0.0.0:50922/ (Press CTRL+C to quit)
2020-05-08T16:14:37.866366+00:00 app[web.1]: INFO:werkzeug: * Restarting with stat
2020-05-08T16:14:38.279279+00:00 heroku[web.1]: State changed from starting to up
2020-05-08T16:14:38.346889+00:00 app[web.1]: WARNING:werkzeug: * Debugger is active!
2020-05-08T16:14:38.365832+00:00 app[web.1]: INFO:werkzeug: * Debugger PIN: 618-739-473
2020-05-08T16:14:40.000000+00:00 app[api]: Build succeeded
2020-05-08T16:15:11.969153+00:00 app[web.1]: INFO:werkzeug:10.186.239.155 - - [08/May/2020 16:15:11] "GET / HTTP/1.1" 404 -
2020-05-08T16:15:11.969938+00:00 heroku[router]: at=info method=GET path="/" host=women-who-read.herokuapp.com request_id=e48ab5b0-3b6b-45d1-84a2-9276d230b941 fwd="182.219.152.173" dyno=web.1 connect=1ms service=5ms status=404 bytes=393 protocol=https
Файловая структура :
~/
|-final/
|--static/
|---fallback.jpg
|---script.js
|---style.css
|--templates/
|---admin_index.html
|---admin_search_result.html
|---index.html
|---layout.html
|---login.html
|---register.html
|---search_result.html
|---wishlist.html
|--application.py
|--final.db
|--helpers.py
|--Procfile
|--requirements.txt
|--runtime.txt
application.py (от начала до индекса):
import psycopg2
import os
from cs50 import SQL
from flask import Flask, flash, render_template, redirect, url_for, request, session, jsonify
from flask_session import Session
from werkzeug.security import generate_password_hash, check_password_hash
from helpers import login_required, lookup, wrongInput, getISBNList, saveInDB, deleteFromDB, getISBNInDB, getAuthorInDB, saveIn, getBookId, deleteFrom, getBookIdIn, getISBNIn
# Configure application
app = Flask(__name__)
app.secret_key = os.urandom(24)
if __name__ == '__main__':
port = int(os.environ.get("PORT",8080))
app.debug = True
app.run(host="0.0.0.0", port=port)
app.config["TEMPLATES_AUTO_RELOAD"] = True
db = SQL(os.environ.get("DATABASE_URL") or "sqlite:///final.db")
@app.route("/", methods=['GET'])
@login_required
def index():
authors = getAuthorInDB()
if request.method == "GET":
result = getISBNInDB()
apiResult = []
currentWish = getBookIdIn("wishlist")
isItInWish = []
for isbn in result:
apiResult.append(lookup(isbn)[0])
if getBookId(isbn) in currentWish:
isItInWish.append(True)
else:
isItInWish.append(False)
return render_template("index.html", result=apiResult, authors=authors, isItInWish=isItInWish)
Procfile:
web: python application.py
runtime.txt
python-3.7.6
requirements.txt:
cs50
Flask
Flask-Session
passlib
SQLAlchemy
psycopg2
requests