diff --git a/app.py b/app.py index 915b3b0..f652c41 100644 --- a/app.py +++ b/app.py @@ -1,7 +1,30 @@ -from flask import Flask, render_template +import os +from flask import Flask, render_template, request, redirect, url_for, session +from flask_sqlalchemy import SQLAlchemy app = Flask("App") +app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:////" + \ + os.path.join(os.path.abspath(os.path.dirname(__file__)), "app.db") +app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False +app.secret_key = "SAFmdsdDkSukyuDd" +db = SQLAlchemy(app) -@app.route("/") -def index(): - return render_template("index.html") \ No newline at end of file +@app.route("/", methods=["POST", "GET"]) +def login(): + if request.method == "POST": + name = request.form["name"] + password = request.form["password"] + session["user_name"] = name + session["user_password"] = password + return redirect(url_for("user_page", user_name=name)) + else: + if "user_name" in session: + return redirect(url_for("user_page", user_name=session["user_name"])) + return render_template("login.html") + + +@app.route("/") +def user_page(user_name): + if not "user_name" in session: + return redirect(url_for("login")) + return render_template("user_page.html") \ No newline at end of file diff --git a/requirements b/requirements new file mode 100644 index 0000000..fd02b61 --- /dev/null +++ b/requirements @@ -0,0 +1,2 @@ +flask +flask-sqlalchemy \ No newline at end of file diff --git a/static/images/default_avatar.png b/static/images/default_avatar.png new file mode 100644 index 0000000..2b83185 Binary files /dev/null and b/static/images/default_avatar.png differ diff --git a/templates/login.html b/templates/login.html new file mode 100644 index 0000000..344e3ec --- /dev/null +++ b/templates/login.html @@ -0,0 +1,33 @@ + + + + Language Learner + + + + + +
+

Language Learner

+
+
+
+
+
+

Log in / Sign up

+ + + + + +
+
+
+
+ + + \ No newline at end of file diff --git a/templates/main.html b/templates/main.html deleted file mode 100644 index b14e51f..0000000 --- a/templates/main.html +++ /dev/null @@ -1,18 +0,0 @@ - - - - App - - - - - -
- -
- - - - \ No newline at end of file diff --git a/templates/user_page.html b/templates/user_page.html new file mode 100644 index 0000000..3eb800f --- /dev/null +++ b/templates/user_page.html @@ -0,0 +1,60 @@ + + + + Language Learner + + + + + +
+

Language Learner

+
+
+
+ avatar +

User Name

+ Interests: +
    +
  • Football
  • +
  • Programming
  • +
  • Something
  • +
+
+
+
+ + +
+
    +
  • + +
  • +
  • + +
  • +
  • + +
  • +
+
+
+
    +
  • + +
  • +
  • + +
  • +
  • + +
  • +
+
+
+ + + \ No newline at end of file