这是我的 app.py 代码:
from flask import Flask
app = Flask(__name__)
from flask import redirect, render_template as rt, url_for, request, flash
import sqlite3
from sqlite3 import Error
con = sqlite3.connect('database.db')
@app.route('/')
def nullPage():
return redirect('/home/')
@app.route('/home/')
def homePage():
return rt('homePage.html')
@app.route('/home/signup/', methods=["get", "post"])
def signUp():
return rt('signUp.html')
@app.route('/home/login/', methods=["get", "post"])
def logIn():
return rt('logIn.html')
@app.route('/home/logedin/', methods=["get", "post"])
def verLogIn():
if request.method == 'post':
passW = request.form['pass']
email = request.form['email']
try:
sql_table(con)
return "Thanks for loging in!"
except Error:
print(Error)
flash(
"An error has occured when talking to the database. Please try again later! Thank you for understanding.",
category='error')
def sql_table(con):
cursorObj = con.cursor()
cursorObj.execute(
"CREATE TABLE credentials(id integer PRIMARY KEY, email text, passWord text)"
)
con.commit()
return print("Commited")
if __name__ == "__main__":
app.secret_key = 'super secret key'
# app.config['SESSION_TYPE'] = 'filesystem'
# sess.init_app(app)
app.debug = True
app.run()
# print("Bye world")```
这是我调用POST方法代码的html代码:
<!-- @format -->
{% extends 'base.html' %} {% block head %}
<div></div>
<link
rel="stylesheet"
href="{{ url_for('static', filename='stylesheets/home.css') }}"
/>
{% endblock %} {% block body %}
<header>
<h1>
Hi, welcome to the WebEmailApp
</h1>
</header>
{% endblock %}
RISEBY
相关分类