Preheat the oven to 400°F (200°C). Line a baking sheet with parchment paper.
Cut the spaghetti squash in half lengthwise and scoop out the seeds. Drizzle the inside of each half with 1 tablespoon of olive oil and season with salt and pepper.
Place the squash halves cut-side down on the prepared baking sheet. Roast in the preheated oven for 30-40 minutes, or until the flesh is easily pierced with a fork.
While the squash is roasting, heat the remaining tablespoon of olive oil in a large skillet over medium heat. Add the chopped onion and cook until translucent, about 5 minutes.
Stir in the minced garlic and cook for an additional minute, until fragrant.
Add the diced tomatoes, black and green olives, oregano, basil, salt, pepper, and red pepper flakes. Simmer the sauce for 15-20 minutes, allowing the flavors to meld.
Once the squash is done, remove it from the oven and let it cool slightly. Using a fork, scrape the strands of squash from the peel and place them in a large bowl.
Pour the tomato and olive sauce over the spaghetti squash strands and toss gently to combine.
Serve the spaghetti squash with tomato sauce and olives garnished with fresh basil and grated Parmesan cheese, if desired.