iOS
- 2 ответа
- 0 вопросов
0
Вклад в тег
class ConnectHandler(webapp.RequestHandler):
def get(self, link_id):
try:
link = LinkModel.gql("WHERE link=:1", link_id).get()
if link is None:
raise LinkNotFoundError
except (db.BadKeyError, LinkNotFoundError):
self.error(400)
return
user_agent = self.request.headers['User-Agent'].lower()
if user_agent.find('ipad') != -1:
self.redirect('/ipad/' + link_id)
elif user_agent.find('iphone') == -1 and user_agent.find('ipod') == -1:
self.redirect('/noiphone')
else:
self.redirect('/iphone/' + link_id)
app = webapp.WSGIApplication(service_mappings + [
(r'/noiphone', NoIphoneHandler),
(r'/iphone/([a-zA-Z0-9-_]{1,256})', IphoneHandler),
(r'/iphoneno', IphoneNoAppHandler),
] )