From f2c44554412b8ef531865c03023ffbe459822cd9 Mon Sep 17 00:00:00 2001 From: zart2007 Date: Thu, 13 Apr 2023 17:44:30 +0800 Subject: [PATCH] 0.1 --- app.py | 26 ++++++++++++++++++++++++++ example/hello.py | 26 ++++++++++++++++++++++++++ example/mysql_conn.py | 22 ++++++++++++++++++++++ templates/hello.html | 15 +++++++++++++++ 4 files changed, 89 insertions(+) create mode 100644 app.py create mode 100644 example/hello.py create mode 100644 example/mysql_conn.py create mode 100644 templates/hello.html diff --git a/app.py b/app.py new file mode 100644 index 0000000..e6d4d38 --- /dev/null +++ b/app.py @@ -0,0 +1,26 @@ +# -*- encoding: utf-8 -*- +''' +@File : app.py +@License : (C)Copyright 2018-2022 + +@Modify Time @Author @Version @Desciption +------------ ------- -------- ----------- +2023/4/13 14:26 zart20 1.0 None +''' + +from flask import Flask, render_template + + +app = Flask(__name__) + +@app.route("/") +def hello(): + return "

hello

" + +@app.route('/hello/') +def hello_2(name): + return render_template('hello.html', name=name) + + +if __name__ == '__main__': + app.run(host="127.0.0.1", port=8080, debug=True) \ No newline at end of file diff --git a/example/hello.py b/example/hello.py new file mode 100644 index 0000000..27c4e5f --- /dev/null +++ b/example/hello.py @@ -0,0 +1,26 @@ +# -*- encoding: utf-8 -*- +''' +@File : hello.py +@License : (C)Copyright 2018-2022 + +@Modify Time @Author @Version @Desciption +------------ ------- -------- ----------- +2023/4/13 12:40 zart20 1.0 None +''' + + +# hello world + +from flask import Flask + +app = Flask(__name__) + +@app.route("/") +def hello(): + return "

Hello, world!

" + + +if __name__ == '__main__': + app.run(host='0.0.0.0', port=5000, debug=True) + + diff --git a/example/mysql_conn.py b/example/mysql_conn.py new file mode 100644 index 0000000..b129116 --- /dev/null +++ b/example/mysql_conn.py @@ -0,0 +1,22 @@ +# -*- encoding: utf-8 -*- +''' +@File : mysql_conn.py +@License : (C)Copyright 2018-2022 + +@Modify Time @Author @Version @Desciption +------------ ------- -------- ----------- +2023/4/13 13:59 zart20 1.0 None +''' + +import pymysql + +db = pymysql.connect(host="127.0.0.1", port=3306, user='root', password="123123", charset="utf8", database="student") + +cursor = db.cursor() + +cursor.execute("show tables;") + +data = cursor.fetchall() +print(data) + +cursor.close() \ No newline at end of file diff --git a/templates/hello.html b/templates/hello.html new file mode 100644 index 0000000..86d7d9b --- /dev/null +++ b/templates/hello.html @@ -0,0 +1,15 @@ + + + + + Hello from flask + + +{% if name %} +

hello {{ name }}!

+{% else %} +

Hello World!

+{% endif %} + + + \ No newline at end of file