תקלה בהעלאת אתר ל־Heroku

תגיות:

נתקלתי בקשיים להעלות את האתר ל-heroku ,
העליתי את כל הקבצים הרלוונטים לrepo שלי בgithub: קובץ app.py, תיקיית templates ותיקיית static שמכילות index.html וindex.css בהתאמה,
התחברתי דרך heroku לאותו repo אבל כשאני עושה deploy branch אני מקבל את השגיאה הבאה:
! No default language could be detected for this app.
HINT: This occurs when Heroku cannot detect the buildpack to use for this application automatically.
See Buildpacks | Heroku Dev Center
! Push failed

מה שכן לא ממש הבנתי כיצד ההקדמה על venv מתחברת לdeploy בheroku, עשיתי את השלבים גם של venv.
אני צריך לעלות לגיטהב את התיקייה של heroku?

  1. אפשר לראות את השגיאה המדויקת?
  2. מה ניסית לחפש בגוגל כדי לפתור?
  1. Build master 51322471

There was an issue deploying your app. View the build log for details.

! No default language could be detected for this app.

HINT: This occurs when Heroku cannot detect the buildpack to use for this application automatically.

See https://devcenter.heroku.com/articles/buildpacks

! Push failed

  1. כתבתי בחיפוש בגוגל את ההודעת שגיאה הזאת.
  1. איזו שגיאה חיפשת? זו הודעה ארוכה יחסית :slight_smile: מה עוד ניסית לחפש?
  2. מה הופיע ב־Build log?

חיפשתי App not compatible with buildpack

הבנתי שזה קשור להמצאות של הקבצים requirements וProcfile, הוספתי את הקבצים האלה לrepo בגיטהב.
קיבלתי הודעה שהdeployment הצליח,
אך כשלחצתי על view קיבלתי את המסך הזה:

בלשונית של הactiviy אני רואה שהלוג שלי הוא:
-----> Python app detected
-----> No change in requirements detected, installing from cache
-----> Installing pip 20.1.1, setuptools 47.1.1 and wheel 0.34.2
-----> Installing SQLite3
-----> Installing requirements with pip
-----> Discovering process types
Procfile declares types -> pip
-----> Compressing…
Done: 45.3M
-----> Launching…
Released v9
https://hagai31.herokuapp.com/ deployed to Heroku

מה מופיע ב־Build log?

לייק 1

כתוב מה שהיה כתוב בלשונית של הactivity:

-----> Python app detected
-----> No change in requirements detected, installing from cache
-----> Installing pip 20.1.1, setuptools 47.1.1 and wheel 0.34.2
-----> Installing SQLite3
-----> Installing requirements with pip
-----> Discovering process types
Procfile declares types -> pip
-----> Compressing…
Done: 45.3M
-----> Launching…
Released v10
https://hagai31.herokuapp.com/ deployed to Heroku

תוכל בבקשה לצלם לי את המסך?

כשאני לוחץ על view:

https://www.google.com/search?client=firefox-b-d&q=how+to+view+build+log+heroku :slight_smile:

לייק 1

זה מה שכתוב לי בview logs:

השגיאה כתובה ממש בשורה השנייה :slight_smile:
לא הוספת את requests ל־reqiurements.txt שלך

לייק 1

תודה רבה , אכן לא היה מותקן לי requests בסביבה הוירטואלית,
האתר עולה יפה:

אבל אני מקבל שגיאה כשאני מכניס קלט כלשהו :
slight_smile: request = request.replace(’{API_KEY}’, API_KEY)
TypeError: replace() argument 2 must be str, not None

אצלי במחשב שמתי את הAPI_KEY בתוך משתנה סביבה, אבל אני רואה שהוא לא זמין לי בheroku

  1. מה לדעתך הבעיה?
  2. איפה ניסית להסתכל כדי לבחון מה הבעיה?
  3. מה ניסית לחפש בגוגל?
  1. הבעיה שמשתני הסביבה שבמחשב שלי לא זמינים ברשת.
    2.אני מחפש בגוגל ויוטיוב דרכים אחרות להחביא את המפתח API, דרך gitignore
  2. ניסיתי לחפש: how to hide api_key using heroku

נראה שיש שגיאה באתר שלך ב־Heroku.
האם ניסית להסתכל ב־log של Heroku?

כן קראתי וקיבלתי שגיאה typerror

TypeError: replace() argument 2 must be str, not None
slight_smile: request = request.replace(’{API_KEY}’, API_KEY)

כשאני משתמש ב:
API_KEY = os.getenv(‘API_KEY’)

אצלי במחשב מתקבל המפתח ממשתנה הסביבה שיצרתי, ממה שאני מבין בheroku לא קיים המפתח, ולכן אני מקבל API_KEY = None

איך הגדרת את משתנה הסביבה ב־Heroku?

לא הגדרתי :sweat_smile:

אוקיי. אז זו הבעיה, אני מאמין. תגדיר :slight_smile:

לייק 1