- Description
- Routes
2.1. /index
2.2. /landing-page
2.3. /create-user
2.4. /passworod
2.5. /login
2.6. /create-event
2.7. /event-list
2.8. /user-list
2.9. /settings
2.10. /records - Functions
- Video Demo
- Technologies Used
- Credits
This code was created for the final project of the CS50 course at Harvard University, aiming to demonstrate the skills developed throughout the course.
SpotSport's main idea is to centralize and promote events that encourage people to become more active and happy, whether it's a simple picnic or a marathon in the city.
In SpotSport, users can find events that best suit their lifestyle.
Esse código foi criado para o projeto final do curso CS50 da Universidade de Harvard, com o objetivo de demonstrar as habilidades desenvolvidas no processo.
O SpotSport tem como ideia principal centralizar e divulgar eventos que incentivem as pessoas a se tornarem mais ativas e felizes, seja através de um simples pique-nique à uma maratona na cidade.
No SpotSport, os usuários podem encontrar eventos que se encaixem melhor em seu estilo de vida.
The /
route checks if a user is logged in. If there is a logged-in user, it redirects to the /home
route. If there is no logged-in user, it renders the /landing-page
.
This route renders a landing page promoting the app.
This route renders a register page.
In this route, the user fills in their information for registration. It's important to note that all fields are mandatory, except for the photo link.
Before allowing a new user to be created, a database query is performed to check if the username
and email
are already in use.
This route renders a "Forgot Password" page that prompts the user to enter their email address to receive a password reset link. And then render the page password-apologize.html.
This route renders a login page where the user must enter their email and password, or click on the "Forgot Password" and "Create Account" links. f the email and password are correct, it will render the app's /home
page. If they are incorrect, a flash message will appear with the text "Invalid email or password."
The /home
route renders a page that displays all the events you are subscribed to and all the events you have created.
- This route uses the
layout.html
template for the header, navigation (nav), and footer. - This route requires login (
@login_required
) to access.
This route allows for creating an event and is triggered by the "New Event" button on the Events page.
All fields are required to be filled in, including event title
, description
, cost
, location
, date
and time
.
- This route uses the
layout.html
template for the header, navigation (nav), and footer. - This route requires login (
@login_required
) to access.
This route is responsible for listing all the events that have been created, allowing users to sign up for them. It also includes a search bar that allows users to search for events by name. Additionally, there is a "Create New Event" button that redirects users to the /events
route.
- This route uses the
layout.html
template for the header, navigation (nav), and footer. - This route requires login (
@login_required
) to access.
This route lists all the registered users on SpotSport, excluding the user who is performing the search.
- This route uses the
layout.html
template for the header, navigation (nav), and footer. - This route requires login (
@login_required
) to access.
This route allows users to change their profile picture and password.
- This route uses the
layout.html
template for the header, navigation (nav), and footer. - This route requires login (
@login_required
) to access. - The photo field accepts only a URL for the image.
This route displays the events in which the user is the creator as well as the events they have signed up for. The POST request for this route is triggered when the user clicks on "Sign Up" on the events page.
- This route uses the
layout.html
template for the header, navigation (nav), and footer. - This route requires login (
@login_required
) to access.
Since it is common in the development environment to delete the database.db file to modify the database, I have decided to insert a countries.json file in the project's root directory. Every time the app starts and there is no data in the countries table, this function will read the .json file and input the data into the database.db.
def populate_countries():
row = session.query(Country).all()
if (len(row) == 0):
file_path = 'countries.json'
with open(file_path, 'r') as file:
json_content = json.load(file)
for item in json_content:
country_name_int = item['country_name_int']
country = Country(country_name_int=country_name_int)
session.add(country)
session.commit()
To avoid issues with threading, it was necessary to use "after_request" to close the sessions.
@app.after_request
def after_request(response):
session.close()
return response
This function returns the logged-in user so that the data can be reused to populate the application's header.
@login_manager.user_loader
def load_user(user_id):
return session.query(User).filter_by(id=user_id).first()
English - Translated with the Captions app AI.
1 - Download or clone the repository to your machine.
2 - Run the command pip install -r requirements.txt
3 - Once all the dependancies have been installed, run the command python app.py
4 - Now simply access the localhost on the port indicated in the prompt, and the app will open.
- Python
- Flask
- HTML
- CSS
- JavaScript
- User icon - Undraw.co
- User photos - This-Person-Does-not-Exist.com
- Country list - Github - jonasruth