A century ago, the 1920 Antwerp Olympics were held only a few months after the Spanish flu ravaged the world, killing at least 50 million people. In 2010, the Vancouver Olympics were threatened by an outbreak of H1N1. In 2016, the Zika virus prompted calls to cancel the Rio Games. And most recently in 2018, officials in Pyeongchang wrestled with an outbreak of the norovirus.
Mass gatherings like the Olympics, that bring together people from all over the world, have always posed a huge infectious disease risk. Visitors bring viruses which may not be endemic to the host country and may take viral souvenirs home to their own communities.
"The opportunities for the movement of infectious diseases are accelerated. We've seen this across Olympic Games, we've seen this in large gatherings like the Hajj or the World Cup," said Dr. John Brownstein, an epidemiologist at Harvard Medical School.
To manage the risk, all Olympic host cities must have a public health plan.
Preparations begin several years earlier when officials start working with the Olympic Organizing Committee to form pandemic preparedness and epidemic surveillance plans. They start monitoring local infections to set a baseline and track viruses or any irregular infection patterns that could pose a threat.
But few Olympic organizers have had to contend with an outbreak of the size and severity of Covid-19. If nothing else, Tokyo 2020 will enter the record books as the Games that came closest to a last-minute cancellation due to rising case numbers.
Here's how other cities have fared.
The world was still reeling from the deaths of tens of millions of people from the Spanish flu when some 2,600 athletes gathered in Antwerp to contest the 1920 Summer Olympics.
It was just two years after World War I and Belgium was still suffering food shortages. The country couldn't afford to build a pool so officials set up a wooden frame in a canal to host the swimming competitions.
Despite the less than desirable conditions, the Games went on without any major problems or outbreaks -- they were seen as a symbol of hope and unity in the post-war, post-pandemic world.
There is always the risk of diseases spreading as people travel, but another concern is the strain an outbreak could put on local health care systems, according to the World Health Organization (WHO).
A community could be prepared to manage an outbreak within its population, but may struggle if that population has ballooned exponentially. In 2012, more than 8 million people attended the London Summer Games, doubling the city's population.
Foreseeing the risks, authorities began public health planning more than seven years ahead of the Games, according to a report published in the Lancet medical journal. Together, they developed a public risk health assessment that would become the foundation of Olympic planning.
The UK already had a strong healthcare monitoring system, but extra surveillance was added for the Games, giving officials daily rather than weekly reports of illnesses and mortality across the country.
The report said officials had realized the urgency of reassuring the public at such a large event. Workers monitored social media to quickly counter rumors of illness with facts.
Public health surveillance methods were improved based on this analysis and would go on to become a legacy of London 2012. Similar risk analysis methods were also used in the planning of Rio 2016.
Ahead of the 2016 Rio Olympics, talk was dominated by the Zika virus, a mosquito-borne disease primarily transmitted through the bite of an infected female Aedes aegypti mosquito.
Symptoms include fever, rash and joint pain, though a Zika virus infection during pregnancy can cause microcephaly, a neurological disorder that results in babies being born with abnormally small heads.
Several high level athletes, such as pro golfer Rory McIlroy, dropped out of the competition due to concerns about the illness.
Before the Games, Brownstein's team created a map to model the potential transmission of the Zika virus from the Olympics -- Brazil was a hotspot and had declared a national public health emergency in 2015.
"We do mining of all these articles and social media posts looking for clues about disease events and different populations across many different languages," Brownstein said. "We use machine learning and AI to go through all that data, filter it, tag it, and then make it available to like WHO and CDC and others."
Researchers mapped areas highly susceptible to the virus, such as parts of Asia and Africa that have dengue outbreaks, countries sending the most athletes, as well as countries with the most travelers from Brazil.
Though the WHO said there were no confirmed cases of Zika among Olympics athletes or travelers, maps like this can help predict and prevent viral transmission ahead of mass gatherings. Though there were no confirmed cases of Zika at Rio, that doesn't mean there were no infections at all since most people don't show symptoms.
While Zika did not have an impact on the Olympics, it continued to torment poorer local communities for months to come. Researchers at UC Berkeley argued the seasonal patterns of diseases similar to Zika predicted Zika's decline ahead of the Games and the diversion of scarce resources to a relatively low-risk population -- wealthy tourists and athletes -- instead of those who were in dire need of them, could have been avoided.
In June 2009, seven months before the start of the Vancouver 2010 Winter Games, the WHO declared H1N1 -- also known as swine flu -- a pandemic.
There were more than 33,000 cases of H1N1 and 428 deaths in Canada during the 2009-2010 flu season, according to Infection Prevention and Control Canada.
"It seems so long ago now, but I remember in the fall of 2009 there were high level discussions about the impact this might have on the Games, and it doesn't seem real now, but at the time, it was very real," said Rob Stewart, Medical Services Operations Manager of Vancouver 2010.
Though the pandemic had largely subsided by the start of the Games, officials were still on high alert.
Public health was considered in every part of the planning process from venue design, setting up hand washing facilities and proper sanitation, to public messaging on cough etiquette and social distancing. Spectators and athletes who weren't able to get vaccinated at home were given free H1N1 jabs on site.
"Every day we could communicate with public health at about 11 o'clock at night and we'd get the stats for the day and then we would go over them," said Dr. Mike Wilkinson, Director of Medical Services at Vancouver 2010.
Daily briefing documents included everything from immunization levels to air quality to any infectious disease outbreaks in the region.
"Influenza activity throughout the region remains well below historical norms. Other respiratory viruses predominate. Drinking water quality data supports tap water as the best choice for visitors and residents," reads a Health Watch report from February 2, 2010, 10 days before the start of the Games.
Ultimately no athletes caught H1N1 at the Vancouver Games. "It's always said of the Games, if I'm the chief medical officer and I'm the one looking around as if I'm not doing anything that means that I've done a good job," said Wilkinson.
Similar precautions were taken in the Pyeongchang 2018 Winter Olympics, where officials battled a norovirus outbreak.
Just days before the opening ceremony, norovirus -- an extremely contagious stomach bug -- spread among security staff at an Olympic accommodation facility, infecting 41 guards.
A total of 1,200 security guards were put in quarantine to limit the spread while testing was conducted. "That's the trick, to catch it early enough," said Stewart, from Vancouver 2010. "Isolate the people that are sick and they stay there. By the time you're looking at a whole team, you're probably quite far down the road. The trick is to catch it right away."
The quarantined staff were quickly replaced with 900 military personnel from South Korea's conscripted army, who had been on standby with extra manpower as part of the contingency plans.
"That is the key of this success, communication among different interest groups is the essential part of the success of the prevention of epidemic outbreak," said Dr. Young-Hee Lee, Chief Medical Officer of Pyeongchang 2018.
Ahead of the Tokyo Olympics, medical officers from previous Games have been sharing their experiences and advice with the current organizing committee, though they admit it's a completely different ball game this time around.
"Everything pales in comparison to what they are having to do now in Tokyo," said Wilkinson, but he said virus surveillance and containment methods remain largely the same.
"We know what works, what historically has worked," he said -- personal hygiene, social distancing, masking, cough etiquette and vaccinations are the foundation of that.
Stewart added: "You plan for the worst and hope for the best."