修复
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
from flask import Flask, request, jsonify
|
||||
from flask import Flask, request, jsonify, render_template
|
||||
from .config import Config
|
||||
from .utils import get_latest_emails, get_latest_email_with_code, add_allowed_domain, remove_allowed_domain, get_allowed_domains, get_allowed_domains_with_time
|
||||
import redis
|
||||
from .smtp_server import start_smtp_server
|
||||
import threading
|
||||
|
||||
def create_app():
|
||||
app = Flask(__name__)
|
||||
@@ -51,4 +54,20 @@ def create_app():
|
||||
domains_with_time = get_allowed_domains_with_time()
|
||||
return jsonify(domains_with_time), 200
|
||||
|
||||
@app.route('/')
|
||||
def list_emails_page():
|
||||
emails = get_latest_emails(count=50)
|
||||
return render_template('email_list.html', emails=emails)
|
||||
|
||||
@app.route('/email/<recipient>')
|
||||
def view_email_page(recipient):
|
||||
email = get_latest_email_with_code(recipient)
|
||||
if email:
|
||||
return render_template('email_detail.html', email=email)
|
||||
return "邮件不存在", 404
|
||||
|
||||
smtp_thread = threading.Thread(target=start_smtp_server, args=(app,))
|
||||
smtp_thread.daemon = True
|
||||
smtp_thread.start()
|
||||
|
||||
return app
|
||||
Reference in New Issue
Block a user