-
Notifications
You must be signed in to change notification settings - Fork 1
/
root.py
39 lines (34 loc) · 1.37 KB
/
root.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
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/env python
import cgi
import datetime
import logging
import models
import webapp2
from google.appengine.ext import ndb
from google.appengine.api import users
class RootPage(webapp2.RequestHandler):
def get(self):
self.response.out.write('<html><body>')
self.response.out.write("""
<form action="/new" method="post">
<div>
<label for="input_url">Input Url (ie: 'test' for 'http://go/test')</label>
<textarea id="input_url" name="input_url" rows="1" cols="60"></textarea>
</div>
<div>
<label for="to_url">To URL (ie: 'http://google.com')</label>
<textarea id="to_url" name="to_url" rows="1" cols="60"></textarea>
</div>
<div><input type="submit" value="Add new redirect"></div>
</form>
<script type="text/javascript">
function getParameterByName(name) {
name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
results = regex.exec(location.search);
return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
}
document.getElementById('input_url').value = getParameterByName('input_url');
</script>
</body>
</html>""")