Skip to content

Commit

Permalink
zkracovac
Browse files Browse the repository at this point in the history
  • Loading branch information
Felix Vybíhal committed Jan 5, 2023
1 parent ad913a5 commit c0497a4
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 1 deletion.
Binary file modified data.db
Binary file not shown.
8 changes: 7 additions & 1 deletion static/styles.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
<li><a href="{{ url_for('info') }}">Info</a></li>
<li><a href="{{ url_for('abc') }}">ABC</a></li>
<li><a href="{{ url_for('malina') }}">Malina</a></li>
<li><a href="{{ url_for('zkracovac') }}">Zkracovač</a></li>
<li><a href="{{ url_for('login') }}">Login</a></li>
<li><a href="{{ url_for('logout') }}">logout</a></li>
<li><a href="{{ url_for('registrace') }}">registrace</a></li>
Expand Down
15 changes: 15 additions & 0 deletions templates/zkracovac.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{% extends 'base.html' %}

{%block title%}Zkracovač{%endblock%}

{% block obsah %}

<h1>Zkracovač URL</h1>

<form method="post"></form>
<p class="url">
Zadej URL:
<input type ="text"name ="url">
<button type="submit">Zkrátit</button>
</p>
{% endblock obsah %}
16 changes: 16 additions & 0 deletions webface.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
from mysqlite import SQLite
from werkzeug.security import generate_password_hash, check_password_hash
import sqlite3
import random
import string

app = Flask(__name__)
app.secret_key = b"totoj e zceLa n@@@hodny retezec nejlep os.urandom(24)"
Expand All @@ -30,6 +32,20 @@ def wrapper(*args, **kwargs):
def index():
return render_template("base.html")

@app.route("/zkracovac/")
def zkracovac():
return render_template("zkracovac.html")

@app.route("/zkracovac/", methods=["POST"])
def zkracovac_post():
url = request.form.get("url")
zkratka = "".join(random.choices(string.ascii_uppercase +string.digits, k=5))
with SQLite("data.db") as cur:
cur.execute( " INSERT INTO adresy (zkratka,adresa) VALUES (?,?) ", [zkratka,url] )

return redirect(url_for("zkracovac"))



@app.route("/info/")
def info():
Expand Down

0 comments on commit c0497a4

Please sign in to comment.