moving repository to gitea

This commit is contained in:
2026-07-26 10:07:10 +02:00
parent 94687f5fc1
commit aaca513e23
59 changed files with 29784 additions and 0 deletions

View File

@@ -0,0 +1,68 @@
{% extends "layout.html" %}
{% block page_title %}Admin Dashboard{% endblock %}
{% block body %}
{{ super() }}
{# only invoked when failed adding new ID due to duplication #}
{% if id_to_add_is_duplicated %}
<div class="alert alert-dismissible alert-danger">
<button type="button" class="close" data-dismiss="alert">&times;</button>
<strong>Warning!</strong> The account name already exists.
</div>
{% endif %}
{# only invoked when failed adding new ID due to invalid character #}
{% if id_to_add_is_invalid %}
<div class="alert alert-dismissible alert-danger">
<button type="button" class="close" data-dismiss="alert">&times;</button>
<strong>Warning!</strong> The account name is invalid.
</div>
{% endif %}
<div class = "container">
<div class="row">
<div class="col-lg-6">
<h3>Add Account</h3>
<form class="form-inline" action="/add_user" method='post'>
<div class="form-group">
<label for="id">ID</label>
<input type="text" class="form-control" name="id">
</div>
<div class="form-group">
<label for="pw">Password</label>
<input type="password" class="form-control" name="pw">
</div>
<br><br>
<button type="submit" class="btn">Submit</button>
</form>
</div>
<div class="col-lg-6">
<h3>Manage Existing Accounts</h3>
<table class="table small">
<thead>
<tr>
<th>#</th>
<th>ID</th>
<th>Action</th>
</tr>
</thead>
{% for number, id, act in users %}
<tr>
<th> {{ number }} </th>
<td> {{ id }} </td>
<td><a href={{act}}>Delete</a></td>
</tr>
{% endfor %}
</table>
</div>
</div>
</div>
{% endblock %}

View File

@@ -0,0 +1,21 @@
{% extends "layout.html" %}
{% block page_title %}Welcome{% endblock %}
{% block body %}
{{ super() }}
<p>hello world</p>
<p>This is a web app developed with <a href="http://flask.pocoo.org/">Flask</a> framework.</p>
<p>The main purpose is to introduce how to implement the essential elements in web applications with Flask, 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>
<li>Invoking static resources</li>
<li>Upload files</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 %}

View File

@@ -0,0 +1,87 @@
<html>
<meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="{{ url_for('static', filename='css/bootstrap.min.united.css') }}">
<script src="{{ url_for('static', filename='js/jquery.min.js') }}"></script>
<script src="{{ url_for('static', filename='js/bootstrap.min.js') }}"></script>
<title>Flask Example</title>
<nav class="navbar navbar-inverse">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="/">Flask Example</a>
</div>
<div class="collapse navbar-collapse" id="myNavbar">
<ul class="nav navbar-nav">
<li><a href="{{ url_for('FUN_root') }}">Home</a></li>
<li><a href="{{ url_for('FUN_public') }}">Public</a></li>
{% if session.get("current_user", None) != None %}
<li><a href="{{ url_for('FUN_private') }}">Private</a></li>
{% endif%}
{% if session.get("current_user", None) == "ADMIN" %}
<li><a href="{{ url_for('FUN_admin') }}">Admin Dashboard</a></li>
{% endif %}
</ul>
<ul class="nav navbar-nav navbar-right">
{% if session.get("current_user", None) == None %}
<form action="/login" method="post" class="navbar-form navbar-right">
<div class="form-group">
<input type="text" name="id" placeholder="User Name" class="form-control">
</div>
<div class="form-group">
<input type="password" name="pw" placeholder="Password" class="form-control">
</div>
<button type="submit" class="btn btn-success">Log In</button>
</form>
{% else %}
<li>
<a><b>{{ session.get("current_user") }}</b></a></li>
<li><a href="{{ url_for('FUN_logout') }}"><b><u>Logout</u></b></a>
</li>
{% endif %}
</ul>
</div>
</div>
</nav>
{% with messages = get_flashed_messages(with_categories=true) %}
{% if messages %}
{% for category, message in messages %}
<div class="alert alert-{{ category }}">
{{ message }}
</div>
{% endfor %}
{% endif %}
{% endwith %}
<div class="container">
<h1>{% block page_title %}{% endblock %}</h1>
<p>{% block body %}{% endblock %}</p>
</div>
<div class='container'>
<hr>
Developed by <a href='https://github.com/XD-DENG'>XD-DENG</a>
<a href="http://flask.pocoo.org/"><img
src="{{ url_for('static', filename='img/flask-powered.png') }}"
border="0"
align="right"
alt="Flask powered"
title="Flask powered"></a>
</div>
</html>

View File

@@ -0,0 +1,6 @@
{% extends "layout.html" %}
{% block page_title %}Unauthorized(401){% endblock %}
{% block body %}
{{ super() }}
You're not allowed to access.
{% endblock %}

View File

@@ -0,0 +1,6 @@
{% extends "layout.html" %}
{% block page_title %}Forbidden(403){% endblock %}
{% block body %}
{{ super() }}
This operation is forbidden.
{% endblock %}

View File

@@ -0,0 +1,6 @@
{% extends "layout.html" %}
{% block page_title %}Not Found (404){% endblock %}
{% block body %}
{{ super() }}
The resource can not be found.
{% endblock %}

View File

@@ -0,0 +1,6 @@
{% extends "layout.html" %}
{% block page_title %}Method not allowd (405){% endblock %}
{% block body %}
{{ super() }}
The method of your request is not allowed.
{% endblock %}

View File

@@ -0,0 +1,6 @@
{% extends "layout.html" %}
{% block page_title %}Request if too big(413){% endblock %}
{% block body %}
{{ super() }}
Please check the file size you're uploading.
{% endblock %}

View File

@@ -0,0 +1,76 @@
{% extends "layout.html" %}
{% block page_title %}Private Page{% endblock %}
{% block body %}
{{ super() }}
<h4>You can take notes here. Only yourself can access them. They will be removed when your account is removed.</h4>
<hr>
<h3>Add Note</h3>
<div class="form-group">
<label for="textArea" class="col-lg-3 control-label">Note to Take</label>
<div class="col-lg-9">
<form action="/write_note" method="post">
<input class="form-control" name="text_note_to_take"></input>
<button type="submit" class="btn btn-success">Submit</button>
</form>
</div>
</div>
<hr>
{% if notes %}
<h3>Your Notes</h3>
<table class="table small">
<thead>
<tr>
<th>Note ID</th>
<th>Timestamp</th>
<th>Note</th>
<th>Action</th>
</tr>
</thead>
{% for note_id, timestamp, note, act in notes %}
<tr>
<td> {{ note_id }} </td>
<td> {{ timestamp }} </td>
<td> {{ note }} </td>
<td><a href={{act}}>Delete</a></td>
</tr>
{% endfor %}
</table>
{% endif %}
<hr>
<h3>Upload Image</h3>
<form method='post' action='/upload_image' enctype=multipart/form-data>
<p><input type=file name=file>
<input type=submit value=Upload>
</form>
{% if images %}
<h3>Your Images</h3>
<table class="table small">
<thead>
<tr>
<th>Image ID</th>
<th>Timestamp</th>
<th>Image Name</th>
<th>Action</th>
</tr>
</thead>
{% for image_id, timestamp, image_name, act in images %}
<tr>
<td> {{ image_id }} </td>
<td> {{ timestamp }} </td>
<td> {{ image_name }} </td>
<td><a href={{act}}>Delete</a></td>
</tr>
{% endfor %}
</table>
{% endif %}
{% endblock %}

View File

@@ -0,0 +1,7 @@
{% extends "layout.html" %}
{% block page_title %}Public Page{% endblock %}
{% block body %}
{{ 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.
{% endblock %}