website for beta festival 2024
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

60 lines
1.8 KiB

4 months ago
from flask import Flask, render_template
import contentful
from dotenv import load_dotenv
import os
import datetime
load_dotenv()
app = Flask(__name__, static_folder='public')
# Set your Contentful space ID and access token
SPACE_ID = os.getenv('SPACE_ID')
ACCESS_TOKEN = os.getenv('ACCESS_TOKEN')
client = contentful.Client(SPACE_ID, ACCESS_TOKEN)
@app.route('/')
def index():
4 months ago
return render_template('index.html', title='Homepage')
@app.route('/events')
def events():
return render_template('list.html', title='Events')
@app.route('/exhibitions')
def exhibitions():
return render_template('list.html', title='Exhibitions')
@app.route('/conferences')
def conference():
return render_template('list.html', title='Conferences')
4 months ago
def get_all_content(type):
content_list = []
entries = client.entries({'content_type': type})
for entry in entries:
date_time_obj = getattr(entry, f'{type}_date_time')
date_str, time_str = format_datetime(date_time_obj)
end_time_str = getattr(entry, f'{type}_end_date_time')
end_time_str = end_time_str.strftime('%I%p').upper().lstrip('0')
content = {
'title': getattr(entry, f'title_of_{type}'),
'information': getattr(entry, f'{type}_information'),
'image': 'https:{0}'.format(getattr(entry, f'{type}_reference_image').url()),
'artists': getattr(entry, f'{type}_artists'),
'date': date_str,
'time': time_str,
'end_time': end_time_str,
'location': getattr(entry, f'{type}_location')
}
content_list.append(content)
print(content_list)
def format_datetime(dt):
date_str = dt.strftime('%d.%m.%y')
time_str = dt.strftime('%I%p').upper().lstrip('0')
return date_str, time_str
if __name__ == '__main__':
app.run(debug=True)