2 Star 10 Fork 1

dusthub/TextToSpeech-for-chinese

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
myapp.py 1.10 KB
一键复制 编辑 原始数据 按行查看 历史
import MySQLdb
from flask import Flask, g, request, render_template, redirect
app = Flask(__name__)
app.debug = True
from sae.const import (MYSQL_HOST, MYSQL_HOST_S,
MYSQL_PORT, MYSQL_USER, MYSQL_PASS, MYSQL_DB
)
@app.before_request
def before_request():
g.db = MySQLdb.connect(MYSQL_HOST, MYSQL_USER, MYSQL_PASS,
MYSQL_DB, port=int(MYSQL_PORT))
@app.teardown_request
def teardown_request(exception):
if hasattr(g, 'db'): g.db.close()
@app.route('/')
def hello():
return "Hello, world! - Flask"
@app.route('/demo', methods=['GET', 'POST'])
def greeting():
html = ''
if request.method == 'POST':
c = g.db.cursor()
c.execute("insert into demo(text) values(%s)", (request.form['text']))
html += """
<form action="" method="post">
<div><textarea cols="40" name="text"></textarea></div>
<div><input type="submit" /></div>
</form>
"""
c = g.db.cursor()
c.execute('select * from demo')
msgs = list(c.fetchall())
msgs.reverse()
for row in msgs:
html += '<p>' + row[-1] + '</p>'
return html
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/DustHar/TextToSpeech-for-chinese.git
git@gitee.com:DustHar/TextToSpeech-for-chinese.git
DustHar
TextToSpeech-for-chinese
TextToSpeech-for-chinese
master

搜索帮助