[1] Refine; [2] Added README
This commit is contained in:
47
README.md
Normal file
47
README.md
Normal file
@@ -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
|
||||||
Binary file not shown.
BIN
static/img/private.jpg
Normal file
BIN
static/img/private.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 77 KiB |
BIN
static/img/public.jpg
Normal file
BIN
static/img/public.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 83 KiB |
@@ -1,8 +1,18 @@
|
|||||||
{% extends "layout.html" %}
|
{% extends "layout.html" %}
|
||||||
{% block page_title %}Welcome to Flask Example{% endblock %}
|
{% block page_title %}Welcome{% endblock %}
|
||||||
{% block body %}
|
{% block body %}
|
||||||
{{ super() }}
|
{{ super() }}
|
||||||
|
|
||||||
<p>In this example, we cover concepts including: </p>
|
<p>This is a minimal web app developed in <a href="http://flask.pocoo.org/">Flask</a>.</p>
|
||||||
<p>template (inheritance), URL building, redirecting, error handeling, session management (authentication), etc.</p>
|
<p>The main purpose is to introduce how to implement the essentail elements in web applications with Flask framework, including</p>
|
||||||
|
<ul>
|
||||||
|
<li>URL Building</li>
|
||||||
|
<li>Authentication with Sessions</li>
|
||||||
|
<li>Template & Template Inheritance</li>
|
||||||
|
<li>Error Handling</li>
|
||||||
|
<li>Integrating with Bootstrap</li>
|
||||||
|
<li>Interaction with Database (SQLite)</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<p>For more basic knowledge of Flask, you can refer to <a href="https://www.tutorialspoint.com/flask/">a tutorial on Tutorialspoint</a>.</p>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
@@ -50,13 +50,13 @@
|
|||||||
|
|
||||||
<div class='container'>
|
<div class='container'>
|
||||||
<hr>
|
<hr>
|
||||||
|
Developed by <a href='https://github.com/XD-DENG'>XD-DENG</a>
|
||||||
<a href="http://flask.pocoo.org/"><img
|
<a href="http://flask.pocoo.org/"><img
|
||||||
src="{{ url_for('static', filename='img/flask-powered.png') }}"
|
src="{{ url_for('static', filename='img/flask-powered.png') }}"
|
||||||
border="0"
|
border="0"
|
||||||
|
align="right"
|
||||||
alt="Flask powered"
|
alt="Flask powered"
|
||||||
title="Flask powered"></a>
|
title="Flask powered"></a>
|
||||||
|
|
||||||
Developed by <a href='https://github.com/XD-DENG'>XD-DENG</a>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -2,5 +2,6 @@
|
|||||||
{% block page_title %}Private Page{% endblock %}
|
{% block page_title %}Private Page{% endblock %}
|
||||||
{% block body %}
|
{% block body %}
|
||||||
{{ super() }}
|
{{ super() }}
|
||||||
|
<img src="{{ url_for('static', filename='img/private.jpg') }}" class="img-circle" alt="Cinque Terre" width="304" height="236">
|
||||||
Only logged-in users, like you, can access this page.
|
Only logged-in users, like you, can access this page.
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
@@ -2,5 +2,6 @@
|
|||||||
{% block page_title %}Public Page{% endblock %}
|
{% block page_title %}Public Page{% endblock %}
|
||||||
{% block body %}
|
{% block body %}
|
||||||
{{ super() }}
|
{{ super() }}
|
||||||
|
<img src="{{ url_for('static', filename='img/public.jpg') }}" class="img-circle" alt="Cinque Terre" width="304" height="236">
|
||||||
You can access this no matter whether you have logged in.
|
You can access this no matter whether you have logged in.
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
Reference in New Issue
Block a user