本文整理匯總了Python中app.app.models方法的典型用法代碼示例。如果您正苦於以下問題:Python app.models方法的具體用法?Python app.models怎麽用?Python app.models使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類app.app
的用法示例。
在下文中一共展示了app.models方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: ping
# 需要導入模塊: from app import app [as 別名]
# 或者: from app.app import models [as 別名]
def ping(service_id):
from app import db, models
from models import Service
finding = Service.query.filter_by(serviceid=service_id).first()
if finding is not None:
image_name = finding.imagename
uploadn = finding.uploadname
usern = finding.username
firstcreatetime = finding.firstcreatetime
u = Service(serviceid = service_id, createdtime = str(time.time()), imagename = image_name, uploadname = uploadn, username = usern, firstcreatetime = firstcreatetime)
db.session.add(u)
db.session.commit()
db.session.delete(finding)
db.session.commit()
else:
return "The service "+service_id+" has been removed!"
return "There are existing service:"+service_id
示例2: setting
# 需要導入模塊: from app import app [as 別名]
# 或者: from app.app import models [as 別名]
def setting():
from app.forms import SetForm
form = SetForm()
if form.validate_on_submit():
servers = models.ServerIP.query.all()
for server in servers:
db.session.delete(server)
db.session.commit()
serverip = form.ip.data
u = models.ServerIP(serverip = serverip)
db.session.add(u)
db.session.commit()
return render_template('setting.html',form=form, succeed = True)
return render_template('setting.html',form=form)
示例3: images
# 需要導入模塊: from app import app [as 別名]
# 或者: from app.app import models [as 別名]
def images():
from app import db, models
images = models.Image.query.all()
result = []
part_line = {'imagename':'default','uploadname':'default','uploaduser':'default','comments':'default'}
for i in images:
part_line['imagename'] = i.imagename
part_line['uploadname'] = i.uploadname
part_line['uploaduser'] = i.uploaduser
part_line['comments'] = i.comments
result.append(part_line)
part_line = {}
return render_template('images.html',imagetables = result)
示例4: idetailed
# 需要導入模塊: from app import app [as 別名]
# 或者: from app.app import models [as 別名]
def idetailed(image_name):
from app import db, models
image = models.Image.query.filter_by(imagename = image_name).first()
published_topics = StringToListOfDict(image.published_topics)
subscribed_topics = StringToListOfDict(image.subscribed_topics)
pub_topic_list = []
sub_topic_list = []
for pub_topic in published_topics:
pub_topic_list.append(pub_topic.get("topic_name"))
for sub_topic in subscribed_topics:
sub_topic_list.append(sub_topic.get("topic_name"))
return render_template('idetailed.html',imagename = image.imagename, uploadname = image.uploadname, uploaduser = image.uploaduser, uploadtime = image.uploadtime, subscribed_topics = sub_topic_list, published_topics = pub_topic_list, advertised_services = StringToList(image.advertised_services), advertised_actions = StringToList(image.advertised_actions), comments = image.comments)