diff --git a/README.md b/README.md new file mode 100644 index 0000000..2176510 --- /dev/null +++ b/README.md @@ -0,0 +1,47 @@ +# flask-example + +A minimal web app developed in [Flask](http://flask.pocoo.org/). + +The main purpose is to introduce how to implement the essential elements in web application with Flask framework, including + +- URL Building + +- Authentication with Sessions + +- Template & Template Inheritance + +- Error Handling + +- Integrating with *Bootstrap* + +- Interaction with Database (SQLite) + +For more basic knowledge of Flask, you can refer to [a tutorial on Tutorialspoint](https://www.tutorialspoint.com/flask/). + + +## Details + +There are three tabs in this toy app + +- **Public**: this is a page which can be accessed by anyone, no matter if the user has logged in or not. + +- **Private**: Only logged-in user can access this page. Otherwise the user will get a 401 error page. + +- **Admin Page**: This part is only open to the user who logged in as "Admin". In this tab, the administrator can manage accounts (list, delete, or add). + + +A few accounts were set for testing, like ***admin*** (password: admin), ***test_1*** (password: 123456), etc. You can also delete or add accounts after you log in as ***admin***. + + +## References + +- http://flask.pocoo.org/ + +- https://www.tutorialspoint.com/flask/ + + + +## Credict +Image private.jpg: https://commons.wikimedia.org/wiki/File:(315-365)_Locked_(6149414678).jpg + +Image public.jpg: https://commons.wikimedia.org/wiki/File:Drown%3F!_(131380682).jpg \ No newline at end of file diff --git a/database_file/users.db b/database_file/users.db index 55b3a22..a1a2f39 100644 Binary files a/database_file/users.db and b/database_file/users.db differ diff --git a/static/img/private.jpg b/static/img/private.jpg new file mode 100644 index 0000000..e666718 Binary files /dev/null and b/static/img/private.jpg differ diff --git a/static/img/public.jpg b/static/img/public.jpg new file mode 100644 index 0000000..5b88caa Binary files /dev/null and b/static/img/public.jpg differ diff --git a/templates/index.html b/templates/index.html index 4114c30..f8f6099 100644 --- a/templates/index.html +++ b/templates/index.html @@ -1,8 +1,18 @@ {% extends "layout.html" %} -{% block page_title %}Welcome to Flask Example{% endblock %} +{% block page_title %}Welcome{% endblock %} {% block body %} {{ super() }} -

In this example, we cover concepts including:

-

template (inheritance), URL building, redirecting, error handeling, session management (authentication), etc.

+

This is a minimal web app developed in Flask.

+

The main purpose is to introduce how to implement the essentail elements in web applications with Flask framework, including

+ + +

For more basic knowledge of Flask, you can refer to a tutorial on Tutorialspoint.

{% endblock %} \ No newline at end of file diff --git a/templates/layout.html b/templates/layout.html index 322e5a1..bd68ca8 100644 --- a/templates/layout.html +++ b/templates/layout.html @@ -50,13 +50,13 @@

+Developed by XD-DENG Flask powered - -Developed by XD-DENG
diff --git a/templates/private_page.html b/templates/private_page.html index 9626942..f1b71c0 100644 --- a/templates/private_page.html +++ b/templates/private_page.html @@ -2,5 +2,6 @@ {% block page_title %}Private Page{% endblock %} {% block body %} {{ super() }} + Cinque Terre Only logged-in users, like you, can access this page. {% endblock %} \ No newline at end of file diff --git a/templates/public_page.html b/templates/public_page.html index c83b906..d716900 100644 --- a/templates/public_page.html +++ b/templates/public_page.html @@ -2,5 +2,6 @@ {% block page_title %}Public Page{% endblock %} {% block body %} {{ super() }} + Cinque Terre You can access this no matter whether you have logged in. {% endblock %} \ No newline at end of file