dongwook-chan commited on
Commit
58913cf
Β·
1 Parent(s): 8d66d27
README.md CHANGED
@@ -1,4 +1,5 @@
1
  # Ice Breaking Challenge
 
2
  ```mermaid
3
  sequenceDiagram
4
  actor user as μ‚¬μš©μž
 
1
  # Ice Breaking Challenge
2
+ ## μ‚¬μš© μ‹œλ‚˜λ¦¬μ˜€
3
  ```mermaid
4
  sequenceDiagram
5
  actor user as μ‚¬μš©μž
app.py CHANGED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ from ice_breaking_challenge import create_app
2
+
3
+ if __name__ == "__main__":
4
+ app = create_app()
5
+ app.run(host="0.0.0.0", port=7860)
flask_session/2029240f6d1128be89ddc32729463129 ADDED
Binary file (9 Bytes). View file
 
flask_session/4b3a5c21ed5e4f46a96be9fe6a0bfb18 ADDED
Binary file (68 Bytes). View file
 
ice_breaking_challenge/__init__.py CHANGED
@@ -1,6 +1,7 @@
1
  import os
2
 
3
- from flask import Flask
 
4
 
5
 
6
  def create_app(test_config=None):
@@ -12,6 +13,8 @@ def create_app(test_config=None):
12
  # store the database in the instance folder
13
  DATABASE=os.path.join(app.instance_path, "flaskr.sqlite"),
14
  )
 
 
15
 
16
  if test_config is None:
17
  # load the instance config, if it exists, when not testing
@@ -31,16 +34,16 @@ def create_app(test_config=None):
31
  return "Hello, World!"
32
 
33
  # register the database commands
34
- from . import db
35
 
36
- db.init_app(app)
37
 
38
  # apply the blueprints to the app
39
- from . import auth
40
- from . import blog
41
 
42
- app.register_blueprint(auth.bp)
43
- app.register_blueprint(blog.bp)
44
 
45
  # make url_for('index') == url_for('blog.index')
46
  # in another app, you might define a separate main index here with
 
1
  import os
2
 
3
+ from flask import Flask, session
4
+ from flask_session import Session
5
 
6
 
7
  def create_app(test_config=None):
 
13
  # store the database in the instance folder
14
  DATABASE=os.path.join(app.instance_path, "flaskr.sqlite"),
15
  )
16
+ app.config['SESSION_TYPE'] = 'filesystem'
17
+ Session(app)
18
 
19
  if test_config is None:
20
  # load the instance config, if it exists, when not testing
 
34
  return "Hello, World!"
35
 
36
  # register the database commands
37
+ # from . import db
38
 
39
+ # db.init_app(app)
40
 
41
  # apply the blueprints to the app
42
+ # from . import auth
43
+ from . import index
44
 
45
+ # app.register_blueprint(auth.bp)
46
+ app.register_blueprint(index.bp)
47
 
48
  # make url_for('index') == url_for('blog.index')
49
  # in another app, you might define a separate main index here with
ice_breaking_challenge/auth.py CHANGED
@@ -11,7 +11,6 @@ from flask import url_for
11
  from werkzeug.security import check_password_hash
12
  from werkzeug.security import generate_password_hash
13
 
14
- from .db import get_db
15
 
16
  bp = Blueprint("auth", __name__, url_prefix="/auth")
17
 
@@ -85,13 +84,8 @@ def register():
85
  def login():
86
  """Log in a registered user by adding the user id to the session."""
87
  if request.method == "POST":
88
- username = request.form["username"]
89
- password = request.form["password"]
90
- db = get_db()
91
- error = None
92
- user = db.execute(
93
- "SELECT * FROM user WHERE username = ?", (username,)
94
- ).fetchone()
95
 
96
  if user is None:
97
  error = "Incorrect username."
 
11
  from werkzeug.security import check_password_hash
12
  from werkzeug.security import generate_password_hash
13
 
 
14
 
15
  bp = Blueprint("auth", __name__, url_prefix="/auth")
16
 
 
84
  def login():
85
  """Log in a registered user by adding the user id to the session."""
86
  if request.method == "POST":
87
+ team_number = request.form["team_number"]
88
+ team_size = request.form["team_size"]
 
 
 
 
 
89
 
90
  if user is None:
91
  error = "Incorrect username."
ice_breaking_challenge/index.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from flask import Blueprint
2
+ from flask import flash
3
+ from flask import g
4
+ from flask import redirect
5
+ from flask import render_template
6
+ from flask import request
7
+ from flask import url_for
8
+ from werkzeug.exceptions import abort
9
+ from flask import session
10
+
11
+ from .auth import login_required
12
+ from .db import get_db
13
+
14
+
15
+ bp = Blueprint("index", __name__)
16
+
17
+
18
+ @bp.route("/", methods=["GET", "POST"])
19
+ def index() -> None:
20
+ match request.method:
21
+ case "GET":
22
+ return render_template("index.html")
23
+ case "POST": # index.htmlμ—μ„œ `λ‹€μŒ` λ²„νŠΌ λˆŒλ €μ„ λ•Œ
24
+ session["team_number"] = request.form.get("team_number")
25
+ session["team_size"] = request.form.get("team_size")
26
+ return render_template("qr.html")
ice_breaking_challenge/introduction.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from flask import Blueprint
2
+ from flask import flash
3
+ from flask import g
4
+ from flask import redirect
5
+ from flask import render_template
6
+ from flask import request
7
+ from flask import url_for
8
+ from werkzeug.exceptions import abort
9
+ from flask import session
10
+
11
+ from .auth import login_required
12
+ from .db import get_db
13
+
14
+
15
+ bp = Blueprint("qr", __name__)
16
+
17
+
18
+ @bp.route("/", methods=["GET", "POST"])
19
+ def qr() -> None:
20
+ match request.method:
21
+ case "GET":
22
+ return render_template("qr.html")
23
+ case "POST": # qr.htmlμ—μ„œ `λ‹€μŒ` λ²„νŠΌ λˆŒλ €μ„ λ•Œ
24
+ return render_template("introduction.html")
ice_breaking_challenge/qr.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from flask import Blueprint
2
+ from flask import flash
3
+ from flask import g
4
+ from flask import redirect
5
+ from flask import render_template
6
+ from flask import request
7
+ from flask import url_for
8
+ from werkzeug.exceptions import abort
9
+ from flask import session
10
+
11
+ from .auth import login_required
12
+ from .db import get_db
13
+
14
+
15
+ bp = Blueprint("qr", __name__)
16
+
17
+
18
+ @bp.route("/", methods=["GET", "POST"])
19
+ def qr() -> None:
20
+ match request.method:
21
+ case "GET":
22
+ return render_template("qr.html")
23
+ case "POST": # qr.htmlμ—μ„œ `λ‹€μŒ` λ²„νŠΌ λˆŒλ €μ„ λ•Œ
24
+ return render_template("qr.html")
ice_breaking_challenge/templates/base.html CHANGED
@@ -1,17 +1,8 @@
1
  <!doctype html>
2
- <title>{% block title %}{% endblock %} - Flaskr</title>
3
  <link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}">
4
  <nav>
5
- <h1><a href="{{ url_for('index') }}">Flaskr</a></h1>
6
- <ul>
7
- {% if g.user %}
8
- <li><span>{{ g.user['username'] }}</span>
9
- <li><a href="{{ url_for('auth.logout') }}">Log Out</a>
10
- {% else %}
11
- <li><a href="{{ url_for('auth.register') }}">Register</a>
12
- <li><a href="{{ url_for('auth.login') }}">Log In</a>
13
- {% endif %}
14
- </ul>
15
  </nav>
16
  <section class="content">
17
  <header>
 
1
  <!doctype html>
2
+ <title>{% block title %}{% endblock %} - Ice Breaking Challenge</title>
3
  <link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}">
4
  <nav>
5
+ <h1><a href="{{ url_for('index') }}">Ice Breaking Challenge</a></h1>
 
 
 
 
 
 
 
 
 
6
  </nav>
7
  <section class="content">
8
  <header>
ice_breaking_challenge/templates/blog/{index.html β†’ index_.html} RENAMED
File without changes
ice_breaking_challenge/templates/index.html ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {% extends 'base.html' %}
2
+
3
+
4
+ {% block content %}
5
+ <form method="post">
6
+ <label for="team_number">νŒ€ 번호</label>
7
+ <input name="team_number" id="team_number" required>
8
+ <label for="team_size">νŒ€μ› 수</label>
9
+ <input name="team_size" id="team_size" required>
10
+ <input type="submit" value="λ‹€μŒ">
11
+ </form>
12
+ {% endblock %}
ice_breaking_challenge/templates/introduction.html ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ {% extends 'base.html' %}
2
+
3
+ {% block content %}
4
+ μžκΈ°μ†Œκ°œ ν•΄λ³΄μ„Έμš”
5
+ <form method="post">
6
+ <input type="submit" value="λ‹€μŒ">
7
+ </form>
8
+ {% endblock %}
ice_breaking_challenge/templates/qr.html ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {% extends 'base.html' %}
2
+
3
+
4
+ {% block content %}
5
+ <button>qr</button>
6
+ <br>
7
+ λͺ¨λ“  νŒ€μ›λ“€μ΄ 섀문을 μ™„λ£Œν•˜λ©΄ μ•„λž˜ λ²„νŠΌμ„ λˆŒλŸ¬μ£Όμ„Έμš”.
8
+ <form method="post">
9
+ <input type="submit" value="λ‹€μŒ">
10
+ </form>
11
+ {% endblock %}
requirements.txt CHANGED
@@ -4,3 +4,5 @@ aiohttp
4
  black[d]
5
  pytest
6
  mypy
 
 
 
4
  black[d]
5
  pytest
6
  mypy
7
+ flask
8
+ Flask-Session