Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Поляков Сергей Викторович
url_shortener
Commits
68eccb65
Commit
68eccb65
authored
Sep 23, 2021
by
Поляков Сергей Викторович
Browse files
4 Part.
Added endpoint GET ('/') for output from DB all links and return to page.
parent
d6e5313b
Pipeline
#3658
failed with stages
in 33 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
main.py
View file @
68eccb65
...
...
@@ -14,7 +14,15 @@ db = DB_Manager(config_class=conf, yaml_manager_class=yaml_manager)
app
=
FastAPI
()
# Home
@
app
.
get
(
"/"
)
def
home
():
all_links
=
{}
for
key
in
db
.
get_keys
():
all_links
.
update
({
key
:
db
.
get_by_key
(
key
)})
return
all_links
# Redirect by short link
@
app
.
get
(
"/{link}"
)
async
def
short_link
(
link
:
str
):
if
db
.
key_exist
(
link
):
...
...
@@ -22,7 +30,7 @@ async def short_link(link: str):
else
:
return
{
'404 Not found'
:
link
}
# Add new link
@
app
.
post
(
"/generate_link/"
)
async
def
add_full_link
(
value
:
str
,
method
:
Optional
[
str
]
=
Query
(
None
)):
if
method
==
'timestamp'
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment