-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathviews
65 lines (58 loc) · 3.27 KB
/
views
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<!DOCTYPE html>
<html>
<head>
<title>URL Shortener</title>
<link rel="shortcut icon" href="https://cdn.hyperdev.com/us-east-1%3A52a203ff-088b-420f-81be-45bf559d01b1%2Ffavicon.ico" type="image/x-icon"/>
<link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet" type="text/css">
<link href="/public/style.css" rel="stylesheet" type="text/css">
</head>
<body>
<div class="container">
<h2>API Project: URL Shortener Microservice</h2>
<h3>
Welcome to my url shortener project!
</h3>
<ul>
<li>Now as far as I understand, how this works is that you enter a url into the box below.</li>
<li>If it's not a valid URL, you'll get a json back saying it's an invalid url</li>
<li>If it's a valid URL, you'll get json back which contains a 'shortened' url, in my case a number.</li>
<li>You then type in the following path into the web-browser like so:</li>
<li>[project_url]/api/shorturl/[number goes here]</li>
<li>Doing this should take you to the website of that url you entered originally.</li>
<li>Good luck on your own projects!</li>
<li>Note that the dns.lookup(host, cb) funtion that we're supposed to use to check for valid urls</li>
<li>doesn't always register valid urls as valid. Notably, if there's "http(s)://" at the front,</li>
<li>the function will say it's invalid. If there's a '/' at the end, it'll say invalid even</li>
<li>though the url works if you type it into the browser. I used regex to trim out these things</li>
<li>so that I pass in a nice, clean url into the dns.lookup function</li>
</ul>
<h3>User Story: </h3>
<ol>
<li>I can POST a URL to <code>[project_url]/api/shorturl/new</code> and I will receive a shortened URL in the JSON response.<br>Example : <code>{"original_url":"www.google.com","short_url":1}</code></li>
<li>If I pass an invalid URL that doesn't follow the <code>http(s)://www.example.com(/more/routes)</code> format, the JSON response will contain an error like <code>{"error":"invalid URL"}</code><br>
HINT: to be sure that the submitted url points to a valid site you can use the function <code>dns.lookup(host, cb)</code> from the <code>dns</code> core module.</li>
<li>When I visit the shortened URL, it will redirect me to my original link.</li>
</ol>
<h3>Short URL Creation </h3>
<p>
example: <code>POST [project_url]/api/shorturl/new</code> - <code>https://www.google.com</code>
</p>
<form action="/api/shorturl/new" method="POST">
<label for="url_input">URL to be shortened</label>
<input id="url_input" type="text" name="url" value="https://www.freecodecamp.org">
<input type="submit" value="POST URL">
</form>
<h3>Example Usage:</h3>
<a href="https://thread-paper.glitch.me/api/shorturl/3">
[this_project_url]/api/shorturl/3
</a>
<h3>Will Redirect to:</h3>
<p>https://www.freecodecamp.org/forum/</p>
</div>
<div class="footer">
<p>
by <a href="https://www.freecodecamp.org">freeCodeCamp</a>
</p>
</div>
</body>
</html>