ABOUT US
-
+ @author yilv
+ this website is based on flask
diff --git a/__pycache__/captcha.cpython-310.pyc b/__pycache__/captcha.cpython-310.pyc index 721ea33..1fe0c4f 100644 Binary files a/__pycache__/captcha.cpython-310.pyc and b/__pycache__/captcha.cpython-310.pyc differ diff --git a/app.db b/app.db index 8dd38a4..8bbccaa 100644 Binary files a/app.db and b/app.db differ diff --git a/app.py b/app.py index 3adcb2d..1c78829 100644 --- a/app.py +++ b/app.py @@ -1,25 +1,29 @@ +#author jason from flask import Flask, render_template, request, redirect, url_for, session, send_file import sqlite3 import os from captcha import generate_captcha from datetime import timedelta + +#init flask and database app = Flask(__name__) app.secret_key = 'your_secret_key' DATABASE = 'app.db' app.config['PERMANENT_SESSION_LIFETIME'] = timedelta(hours=1) app.config['SESSION_COOKIE_SAMESITE'] = 'Lax' + def get_db_connection(): conn = sqlite3.connect(DATABASE) conn.row_factory = sqlite3.Row return conn - +#index.html load the homepage(index.html) and load the information from database @app.route('/') def index(): conn = get_db_connection() posts = conn.execute('SELECT * FROM posts ORDER BY created_at DESC').fetchall() conn.close() return render_template('index.html', posts=posts) - +#signin.html load the page and get post from the form ,confirm users account and key @app.route('/signin', methods=['GET', 'POST']) def signin(): if request.method == 'POST': @@ -44,6 +48,7 @@ def signin(): session['captcha'] = captcha_text return render_template('signin.html', captcha_image=captcha_image) +#signup.html sign up and add accout and keys information into database @app.route('/signup', methods=['GET', 'POST']) def signup(): if request.method == 'POST': @@ -56,7 +61,7 @@ def signup(): if password != confirm_password: return 'Passwords do not match' - if captcha != session.get('captcha', ''): + if captcha != session.get('captcha', ''): #this part will be change ,give user a window ,rather than a new page return 'Invalid captcha' conn = get_db_connection() @@ -82,6 +87,7 @@ def captcha(): session['captcha'] = captcha_text return send_file(captcha_image, mimetype='image/png') + @app.route('/dashboard') def dashboard(): if 'user' not in session: @@ -134,6 +140,14 @@ def logout(): @app.route('/aboutus') def aboutus(): return render_template('aboutus.html') - +@app.route('/commands') +def commands(): + return render_template('commands.html') +@app.route('/python') +def python(): + return render_template('python.html') +@app.route('/video') +def video(): + return render_template('video.html') if __name__ == '__main__': app.run(debug=True) diff --git a/captcha.py b/captcha.py index cc40b25..dbcbb6c 100644 --- a/captcha.py +++ b/captcha.py @@ -9,7 +9,7 @@ def generate_captcha(): font = ImageFont.truetype("arial.ttf", 24) draw = ImageDraw.Draw(image) draw.text((10, 0), captcha_text, font=font, fill=(0, 0, 0)) - + buffer = BytesIO() image.save(buffer, format="PNG") buffer.seek(0) diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..bd9b8bc --- /dev/null +++ b/readme.md @@ -0,0 +1,9 @@ + +include pages: +index +signin +signup +dashboard +user +aboutus + diff --git a/static/1.mp4 b/static/1.mp4 new file mode 100644 index 0000000..78cabbc Binary files /dev/null and b/static/1.mp4 differ diff --git a/static/python_css.css b/static/python_css.css new file mode 100644 index 0000000..e2be5ca --- /dev/null +++ b/static/python_css.css @@ -0,0 +1,113 @@ +/* 导航栏以及body样式 */ +body { + font-family: Arial, sans-serif; + margin: 0; + padding: 0; + box-sizing: border-box; +} + +header { + background-color: #333; + color: white; + padding: 10px 0; + text-align: right; +} + +header nav ul { + list-style: none; + margin: 0; + padding: 0; +} + +header nav ul li { + display: inline; + margin-right: 20px; +} + +header nav ul li a { + color: white; + text-decoration: none; +} + + +main { + padding: 20px; +} + + + + +/* Footer 样式 */ +.footer-container { + background-color: #333; + color: white; + padding: 20px 0; + display: flex; + justify-content: center; + align-items: center; +} + +.footer-item { + margin: 0 20px; +} + +.footer-item a { + color: white; + text-decoration: none; + font-weight: bold; +} + +.footer-item a:hover { + color: #ddd; +} +/* 内容列表样式 */ +#content-list { + margin-top: 20px; +} + +.content-item { + border: 1px solid #ccc; + padding: 10px; + margin-bottom: 10px; + background-color: #f9f9f9; + display: flex; + justify-content: space-between; + align-items: center; +} + +.content-item ul{ + list-style-type: none; +} + +.content-item ul li{ + line-height: 2; +} +/*sidebar样式 */ +.container { + display: flex; +} + +.sidebar { + width: 250px; + background-color: #333; + color: white; + padding: 15px; + box-sizing: border-box; + height: 100vh; + position: fixed; +} + +#content-list { + margin-left: 270px; /* 确保内容不会被侧边栏覆盖 */ + padding: 20px; + box-sizing: border-box; + width: calc(100% - 270px); +} +.sidebar ul li a{ + color: white; +} +.sidebar ul li { + padding: 10px; + text-align: left; + margin-bottom: 10px; /* 增加底部间距 */ +} diff --git a/static/style.css b/static/style.css index e376e16..37d5cb2 100644 --- a/static/style.css +++ b/static/style.css @@ -28,6 +28,11 @@ header nav ul li a { color: white; text-decoration: none; } +/* header nav ul li:first-child{ + float: left; + font-size: x-large; +} */ + main { padding: 20px; @@ -79,6 +84,29 @@ button:hover { font-weight: bold; } +/* Footer 样式 */ +.footer-container { + background-color: #333; + color: white; + padding: 20px 0; + display: flex; + justify-content: center; + align-items: center; +} + +.footer-item { + margin: 0 20px; +} + +.footer-item a { + color: white; + text-decoration: none; + font-weight: bold; +} + +.footer-item a:hover { + color: #ddd; +} /* Dashboard 样式 */ .dashboard { max-width: 150%; @@ -198,9 +226,7 @@ button:hover { .user-posts { margin-top: 20px; } - .user-posts .content-item { - border: 1px solid #ccc; padding: 10px; margin-bottom: 10px; background-color: #f9f9f9; @@ -224,3 +250,33 @@ button:hover { .logout-button:hover { background-color: #555; } + + +.container { + display: flex; +} + +.sidebar { + width: 250px; + background-color: #333; + color: white; + padding: 15px; + box-sizing: border-box; + height: 100vh; + position: fixed; +} + +#content-list { + margin-left: 270px; /* 确保内容不会被侧边栏覆盖 */ + padding: 20px; + box-sizing: border-box; + width: calc(100% - 270px); +} +.sidebar ul li a{ + color: white; +} +.sidebar ul li { + padding: 10px; + text-align: left; + margin-bottom: 10px; /* 增加底部间距 */ +} diff --git a/templates/aboutus.html b/templates/aboutus.html index cbe8242..4c14a89 100644 --- a/templates/aboutus.html +++ b/templates/aboutus.html @@ -9,11 +9,12 @@
-
+ @author yilv
+ this website is based on flask