Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
U
url_shorter_docker
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jonas Leder
url_shorter_docker
Commits
0962fb04
Commit
0962fb04
authored
5 years ago
by
Jonas Leder
Browse files
Options
Downloads
Patches
Plain Diff
fixed some bugs
parent
e265f02f
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
Dockerfile
+1
-1
1 addition, 1 deletion
Dockerfile
main.py
+12
-12
12 additions, 12 deletions
main.py
templates/home.html
+2
-1
2 additions, 1 deletion
templates/home.html
with
15 additions
and
14 deletions
Dockerfile
+
1
−
1
View file @
0962fb04
...
...
@@ -3,7 +3,7 @@
# OS Support also exists for jessie & stretch (slim and full).
# See https://hub.docker.com/r/library/python/ for all supported Python
# tags from Docker Hub.
FROM
python:
latest
FROM
python:
3
# If you prefer miniconda:
#FROM continuumio/miniconda3
...
...
This diff is collapsed.
Click to expand it.
main.py
+
12
−
12
View file @
0962fb04
...
...
@@ -6,15 +6,20 @@ import os
str_encode
=
str
.
encode
app
=
Flask
(
__name__
)
domain
=
"
127.0.0.1:5000;2;3
"
.
split
(
"
;
"
)
#os.environ["domains"].split(";")
domain_to_index
=
{}
domain_prepared
=
""
builddate
=
""
#if(os.environ["show_build_date"] == "1")
:
#
builddate = ", Build date: " + open("builddate.txt", "r").read()
try
:
domain
=
os
.
environ
[
"
domains
"
].
split
(
"
;
"
)
except
:
domain
=
[
"
127.0.0.1:5000
"
]
builddate
=
""
try
:
if
(
os
.
environ
[
"
show_build_date
"
]
==
"
1
"
):
builddate
=
"
, Build date:
"
+
open
(
"
builddate.txt
"
,
"
r
"
).
read
()
except
:
pass
index
=
0
for
domains
in
domain
:
...
...
@@ -73,11 +78,6 @@ def home():
def
throw404
():
abort
(
404
)
@app.route
(
'
/style.css
'
)
def
stylesheet
():
content
=
get_file
(
'
style.css
'
)
return
Response
(
content
,
mimetype
=
"
text/css
"
)
@app.route
(
'
/<short_url>
'
)
def
redirect_short_url
(
short_url
):
host
=
request
.
headers
[
'
Host
'
]
...
...
@@ -94,6 +94,7 @@ def redirect_short_url(short_url):
error_404
=
True
except
Exception
as
e
:
print
(
e
)
abort
(
500
)
if
not
error_404
:
return
redirect
(
url
)
else
:
...
...
@@ -101,6 +102,5 @@ def redirect_short_url(short_url):
if
__name__
==
'
__main__
'
:
# This code checks whether database table is created or not
table_check
()
table_check
()
# This code checks whether database table is created or not
serve
(
app
,
host
=
'
0.0.0.0
'
,
port
=
5000
)
This diff is collapsed.
Click to expand it.
templates/home.html
+
2
−
1
View file @
0962fb04
...
...
@@ -13,6 +13,7 @@
Domain:
<select
name=
"domain"
id=
"domain"
>
{{domain | safe}}
</select>
<br><p>
</p>
<input
id=
"short"
name=
"short"
type=
"text"
placeholder=
"short name"
value=
"{{short_url_prefilled}}"
/>
<button>
short
</button>
<p
class=
"message"
>
©
Made by jonasled {{builddate}}
</p>
...
...
@@ -22,7 +23,7 @@
{% endif %}
</div>
</div>
<div
id=
"snackbar"
>
URL already
choosen
</div>
<div
id=
"snackbar"
>
URL already
used, please try another one
</div>
{% if alreadychoosen %}
<script>
var
x
=
document
.
getElementById
(
"
snackbar
"
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment