-
Notifications
You must be signed in to change notification settings - Fork 0
/
ninjas.py
26 lines (21 loc) · 832 Bytes
/
ninjas.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import os
import webapp2
import jinja2
import logging
class ninjas(webapp2.RequestHandler):
def get(self):
#launch the jinja environment
jinja_environment = jinja2.Environment(loader=jinja2.FileSystemLoader(os.path.dirname(__file__)))
#check user-agent to see if user is mobile or not
#get the user-agent
uastring = str(self.request.headers['user-agent'])
if 'Mobile' in uastring:
logging.info('THIS IS A MOBILE DEVICE')
#serve mobile landing page
template = jinja_environment.get_template('templates/ninjas_landing_mobile.html')
else:
logging.info('THIS IS A DESKTOP DEVICE')
#serve desktop landing page
template = jinja_environment.get_template('templates/ninjas_landing.html')
self.response.out.write(template.render())
app = webapp2.WSGIApplication([('/ninjas', ninjas)],debug=True)