Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python

Trying to replicate this PHP Stumbleupon like code into Flask

Hi guys. I'm trying to replicate some code into flask but I just can't imagine how can this be accomplish. It's a Stumbleupon like website but it's only the iFrame loading different websites, it's very simple. I've learn Flask through the courses but I'm trying to replicate a simple PHP code into Flask. If anyone would like to help I will really appreciated.

Here is the simple PHP code:

index.php

<?php
@$do = $_REQUEST['do'];
$urls = array(
'http://www.google.co.uk',
'http://www.hotmail.com'
); 

if(isset($do) or !$do){ 
  $max = count($urls);
  $stumble = rand(0,$max); 
  require("taskbar.php"); 
  echo "<br /><br /><iframe frameborder='0' noresize='noresize' style='position: absolute; background: transparent; width: 100%; height:100%;' src='$urls[$stumble]' />This Site uses iFrames</iframe>"; 
echo "<div>Hello</div>";
}
?>

taskbar.php

<div align="center"><a href="?do=stumble" />Stumble</a></div><br /><br />