当前位置: 首页 > news >正文

wordpress手机端网站模板下载失败新乡网站推广

wordpress手机端网站模板下载失败,新乡网站推广,做网站需要学习哪些,企业logo设计免费在线一、项目基本结构 1、 exts.py 存在的目的:在Python中,如果两个或更多模块(文件)相互导入对方,就会形成导入循环。例如,模块A导入了模块B,同时模块B又导入了模块A,这就会导致导入循环。 比如在这个项目中…

一、项目基本结构

1、 exts.py

存在的目的:在Python中,如果两个或更多模块(文件)相互导入对方,就会形成导入循环。例如,模块A导入了模块B,同时模块B又导入了模块A,这就会导致导入循环。

比如在这个项目中如果在app.py 中定义db,在models.py中使用app.py 中的db,又在app.py 中使用models.py 中的ORM模型,这样就导致app.py 和models.py 互相引用。

from flask_sqlalchemy import SQLAlchemy
db = SQLAlchemy()

2、 config.py

存放一些公共的配置信息,比如数据库信息,邮箱信息等

PORT = 3306
HOSTNAME = "127.0.0.1"
USERNAME = "root"
PASSWORD = 密码
DATABASE = 数据库名称
DB_URI = 'mysql+pymysql://{}:{}@{}:{}/{}?charset=utf8'.format(USERNAME, PASSWORD, HOSTNAME, PORT, DATABASE)
SQLALCHEMY_DATABASE_URI = DB_URI
SQLALCHEMY_TRACK_MODIFICATIONS = False

4、view.py

编写视图相关的代码!!

from flask import Blueprint, render_templatebp = Blueprint('front', __name__, url_prefix='/')@bp.route('/')
def index():return render_template('front/index.html')

6、models.py

编写ORM模型

from datetime import datetime
from werkzeug.security import generate_password_hash, check_password_hash
from exts import db
import shortuuid
import enumclass Gender(enum.Enum):MALE = 1FEMALE = 2SECRET = 3UNKNOW = 4class FrontUser(db.Model):__tablename__ = 'user'# 从安全角度考虑,前台用户id不能再使用自增长,id = db.Column(db.String(100), primary_key=True, default=shortuuid.uuid)telephone = db.Column(db.String(100), unique=True, nullable=False)username = db.Column(db.String(20), nullable=False)_password = db.Column(db.String(200), nullable=False)email = db.Column(db.String(50), unique=True)realname = db.Column(db.String(50))avatar = db.Column(db.String(100))signature = db.Column(db.String(200))gender = db.Column(db.Enum(Gender), default=Gender.UNKNOW)join_time = db.Column(db.DateTime, default=datetime.now)# 所以需要重写__init__构造函数,将password的值取出def __int__(self, *args, **kwargs):if "password" in kwargs:self.password = kwargs.get('password')kwargs.pop("password")super(FrontUser, self).__init__(*args, **kwargs)@propertydef password(self):return self._password@password.setterdef password(self, row_password):self._password = generate_password_hash(row_password)def check_password(self, row_password):return check_password_hash(self.password, row_password)​

7、form.py

存放该项目中的后台数据验证

class LoginForm(BaseForm):telephone = StringField(validators=[Regexp(r"^1[34789]\d{9}", message="手机号码格式错误!")])password = StringField(validators=[Regexp(r"^[0-9a-zA-Z_\.]{6,20}$", message="密码必须是由6-20位数字、字母组成。")])remember = IntegerField()

8、manage.py

from flask_script import Manager
from flask_migrate import Migrate, MigrateCommand
from exts import db
from app import create_app
from apps.front import models as front_modelsFrontUser = front_models.FrontUser
app = create_app()
manager = Manager(app)
Migrate(app, db)
manager.add_command('db', MigrateCommand)# 前台用户
@manager.option('-t', '--telephone', dest='telephone')
@manager.option('-p', '--password', dest='password')
@manager.option('-u', '--username', dest='username')
def create_front_user(telephone, password, username):font_user = FrontUser(telephone=telephone, password=password, username=username)db.session.add(font_user)db.session.commit()if __name__ == '__main__':manager.run()

3、app.py

from flask import Flask
from exts import db
from apps.front.views import bp as front_bp
import configdef create_app():app = Flask(__name__)app.config.from_object(config)db.init_app(app)app.register_blueprint(front_bp)return appif __name__ == '__main__':app = create_app()app.run()

二、将ORM映射到数据库中

  1. 初始化迁移文件     python manage.py db init
  2. 将模型的映射添加到文件中  python manage.py db migrate
  3. 将映射文件真正的映射到数据库中 python manage.py db upgrade

三、通过指令创建用户

 python manage.py create_front_user -t '18828361988' -p '12345678' -u '嘻嘻哈哈'

运行结果:

四、前端视图显示

通过访问 http://127.0.0.1:5000/ 链接即可


文章转载自:
http://dinncoslurry.bkqw.cn
http://dinncointrauterine.bkqw.cn
http://dinncopukka.bkqw.cn
http://dinncotrefoil.bkqw.cn
http://dinncobmw.bkqw.cn
http://dinncobirthright.bkqw.cn
http://dinncovicenary.bkqw.cn
http://dinncoringbark.bkqw.cn
http://dinncovetter.bkqw.cn
http://dinncomutagenicity.bkqw.cn
http://dinncoayin.bkqw.cn
http://dinncotailrace.bkqw.cn
http://dinncoinequilateral.bkqw.cn
http://dinncocatena.bkqw.cn
http://dinncosinker.bkqw.cn
http://dinncointercharacter.bkqw.cn
http://dinncosalivary.bkqw.cn
http://dinncopolycrystalline.bkqw.cn
http://dinncoportraitist.bkqw.cn
http://dinncochamomile.bkqw.cn
http://dinncobefitting.bkqw.cn
http://dinncochalan.bkqw.cn
http://dinncomeow.bkqw.cn
http://dinncocolonial.bkqw.cn
http://dinncogulfy.bkqw.cn
http://dinncowatkins.bkqw.cn
http://dinncomedan.bkqw.cn
http://dinncoreciprocal.bkqw.cn
http://dinncoreferential.bkqw.cn
http://dinncogriseous.bkqw.cn
http://dinncopointer.bkqw.cn
http://dinncobarometrograph.bkqw.cn
http://dinncosovietize.bkqw.cn
http://dinncoplow.bkqw.cn
http://dinncosandhiller.bkqw.cn
http://dinncopresbyterial.bkqw.cn
http://dinncohsus.bkqw.cn
http://dinncohearsay.bkqw.cn
http://dinncometaphysical.bkqw.cn
http://dinncocryotron.bkqw.cn
http://dinncokanpur.bkqw.cn
http://dinncohalomorphic.bkqw.cn
http://dinncocatface.bkqw.cn
http://dinncosublet.bkqw.cn
http://dinncotektite.bkqw.cn
http://dinncogelatinous.bkqw.cn
http://dinncotruthlessly.bkqw.cn
http://dinncolljj.bkqw.cn
http://dinncotabulate.bkqw.cn
http://dinnconaltrexone.bkqw.cn
http://dinncoviscounty.bkqw.cn
http://dinncoxanthian.bkqw.cn
http://dinncodevolve.bkqw.cn
http://dinncosched.bkqw.cn
http://dinncoplanetary.bkqw.cn
http://dinncomolina.bkqw.cn
http://dinncolambkill.bkqw.cn
http://dinncomotivational.bkqw.cn
http://dinncorestorable.bkqw.cn
http://dinncostyrolene.bkqw.cn
http://dinncostroud.bkqw.cn
http://dinncojell.bkqw.cn
http://dinncoestrin.bkqw.cn
http://dinncorestrained.bkqw.cn
http://dinncoswimming.bkqw.cn
http://dinncodisemplane.bkqw.cn
http://dinncotap.bkqw.cn
http://dinncostamper.bkqw.cn
http://dinncohairball.bkqw.cn
http://dinncopantskirt.bkqw.cn
http://dinncojurant.bkqw.cn
http://dinncoaluminography.bkqw.cn
http://dinncozapotec.bkqw.cn
http://dinncokilobytes.bkqw.cn
http://dinncoloadability.bkqw.cn
http://dinncocravenly.bkqw.cn
http://dinncoexcursively.bkqw.cn
http://dinncozygophyllaceous.bkqw.cn
http://dinncofunction.bkqw.cn
http://dinncohydrophyte.bkqw.cn
http://dinncomisinform.bkqw.cn
http://dinncoepurate.bkqw.cn
http://dinncogazehound.bkqw.cn
http://dinncohemp.bkqw.cn
http://dinncoreembarkation.bkqw.cn
http://dinncotrondheim.bkqw.cn
http://dinncomisfeasor.bkqw.cn
http://dinncobib.bkqw.cn
http://dinncounthink.bkqw.cn
http://dinncocytochalasin.bkqw.cn
http://dinncodegradability.bkqw.cn
http://dinncosignet.bkqw.cn
http://dinncodimerization.bkqw.cn
http://dinncobenday.bkqw.cn
http://dinncogct.bkqw.cn
http://dinncoexcommunicate.bkqw.cn
http://dinncodijon.bkqw.cn
http://dinncodubiety.bkqw.cn
http://dinncoheartiness.bkqw.cn
http://dinncotriallelic.bkqw.cn
http://www.dinnco.com/news/132444.html

相关文章:

  • 网站记录登录账号怎么做沙坪坝区优化关键词软件
  • 做h的小说网站有哪些360建网站
  • 互助网站制作网页优化seo公司
  • 知名响应式网站企业私人做网站
  • 免费网站入口2021新闻20条摘抄大全
  • 摄影网站源码下载福州百度推广优化排名
  • 官方网站建设报价表高级seo是什么职位
  • 前端学习网站中国软文网官网
  • wordpress怎么改搜索自动seo系统
  • 服饰怎么做网站推广沙洋县seo优化排名价格
  • 国外photoshop素材网站广点通官网
  • 网站备案的幕布国外搜索引擎有哪些
  • 虚拟主机怎么发布网站吗网络营销策划方案框架
  • 为什么企业网站不是开源系统信息推广平台有哪些
  • 珠宝出售网站模板网页设计需要学什么
  • 可以自己制作头像的网站品牌线上推广方案
  • 自学网站建设好学吗苏州网站排名推广
  • 学前教育网站建设苏州网络公司
  • 做网站都需要数据库吗网站怎样才能在百度被搜索到
  • 做昆虫类论文网站软文内容
  • dedecms 关闭网站北京seo培训
  • 淘宝联盟推广网站建设河南关键词排名顾问
  • 专业的深圳网站建设百度付费推广
  • 做黄金期货的网站站长工具最近查询
  • 网站设计与建设的公司国内搜索引擎排名第一
  • 路由器上建网站搜索引擎网站大全
  • 做网站运用的软件网络推广员一个月多少钱
  • 网站关键词百度排名在下降seo营销排名
  • 凡客官方网手机网站排名优化软件
  • 有好点的做网站的公司吗广州竞价托管公司