Flask app not loading images, other pages

0

Hello all, I am new to AWS. I have made a flask app in python for my website. Before hosting it, I of course have tested it in my localhost, and it ran successfully. Then I hosted it following https://github.com/yeshwanthlm/YouTube/blob/main/flask-on-aws-ec2.md After that I hosted it in AWS. The funny thing is, although it the index page runs, I cannot see any images/videos/musics that are stored in static/images or static/videos and so on (static folder is in the same directory as the app.py). Moreover, the other homepages are not working. To recreate: app.py:

from flask import Flask, request, redirect, session, url_for, render_template, flash

app = Flask(__name__)

# Index route
@app.route('/')
def index():
    return render_template('index.html')

# Team route
@app.route('/team')
def team():
    return render_template('team.html')

index.html:

<div class="top-bar">
		<div class="logo">
		  <img src="static/images/logo.png" alt="my website">ThinkLabsAI
		</div>
		<div class="menu">
		  <a href="#">Home</a>
		  <a href="/team">Meet the Team</a>
		  <a href="/connect">Connect</a>
		</div>
	  </div>

Thanks!

zak
질문됨 일 년 전626회 조회
1개 답변
0

What happens if I change app.py like this?

app = Flask(__name__, static_folder='./static/images/')
profile picture
전문가
답변함 일 년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠