def signup(): if 'username' in session: return redirect(url_for("index.index")) if request.method == 'POST': username = request.form.get('username') passwd = request.form.get('passwd') passwd2 = request.form.get('passwd2') auth_code = request.form.get('input_auth_code') current = users.query.filter_by(email=username).first() if current: return render_template('usercontrol/signup.html', msg="该邮箱已被注册,请重新输入!") if passwd != passwd2: return render_template('usercontrol/signup.html', msg="两次输入的密码不相同!") #创建一个用户数据类 try: code = escape(session[username]) except: code = None if auth_code != code: return render_template('usercontrol/signup.html', msg="验证码错误!") #默认昵称为邮箱名去掉@xxx.com default_name = username.split('@')[0] #默认头像图片 default_pic = '/static/images/defaultpic.jpg' new = users(username, hash_string(passwd), name=default_name, head_pic=default_pic) #提交到数据库 db_session.add(new) db_session.commit() session['username'] = default_name session['email'] = username session['userid'] = new.id session['level'] = 9 session['head_pic'] = default_pic logging.info(new.id) try: #删除写入session的注册验证码 del session[username] except: pass return redirect(url_for("index.index")) return render_template('usercontrol/signup.html', msg='')
def initialize(): print("Lade Landkreise herunter. Das kann etwas dauern.") openURL = urllib.request.urlopen( 'https://services7.arcgis.com/mOBPykOjAyBO2ZKk/arcgis/rest/services/RKI_Landkreisdaten/FeatureServer/0/query?where=1%3D1&outFields=GEN,Shape__Length,cases7_per_100k,RS,BL,BEZ&outSR=4326&f=json' ) if (openURL.getcode() == 200): data = json.loads(openURL.read()) neueKreise = [] for kreis in data["features"]: coordinates = [] for ring in kreis["geometry"]["rings"]: a = vw.simplify(ring, ratio=0.1) for pair in a: tmp = pair[0] pair[0] = pair[1] pair[1] = tmp coordinates.append(a) if not districts.query.get(int(kreis["attributes"]["RS"])): dnew = districts( int(kreis["attributes"]["RS"]), kreis["attributes"]["GEN"], int(kreis["attributes"]["cases7_per_100k"]), coloring(int(kreis["attributes"]["cases7_per_100k"])), [], coordinates, kreis["attributes"]["BEZ"]) dnew.region = createRegionIfNotExists( kreis["attributes"]["BL"]) db.session.add(dnew) db.session.flush() neueKreise.append(int(kreis["attributes"]["RS"])) with open('links.json') as f: data = json.load(f) for d in data: if d["id"] in neueKreise: dist = districts.query.get(d["id"]) dist.links = [{ "href": d["link"], "title": "Zur Webseite des Kreises" }] if not users.query.filter(users.username == "cms").first( ): #TODO: REMOVE THIS FOR PRODUCTION!!!! (and add hashing) u = users("cms", "pw") db.session.add(u) db.session.commit() else: print("ERROR loading Landkreise")
def sign_up(): if request.method == 'POST': info = request.form if None in info.items(): return '请填写参数' email = users.query.filter_by(email=info['email']).first() if email: return '邮箱已注册' username = users.query.filter_by(username=info['username']).first() if username: return '用户名已占用' user = users() user.email = info['email'] user.username = info['username'] user.password = info['password'] db.session.add(user) db.session.commit() login(user, remember = False) return render_template('debug.html', debug = session) return render_template('signup.html')
db_port = configs.get('db_config').get('port') or 3306 db_username = configs.get('db_config').get('username') or 'root' db_password = configs.get('db_config').get('password') or '' db_name = configs.get('db_config').get('database') or 'GImageDashboard' # Initialize app app = Flask(__name__) app.config.update(DEBUG=True, SQLALCHEMY_DATABASE_URI='mysql://%s:%s@%s:%s/%s' % (db_username, db_password, db_host, db_port, db_name), OAUTH1_PROVIDER_ENFORCE_SSL=False, SEND_FILE_MAX_AGE_DEFAULT=0) # Initialize db db = SQLAlchemy(app) Users, favorite_images, pinned_pages, pinned_500px, pinned_flickr = users(db) Images = images(db) Pages = pages(db) _500pxdb = _500px_model(db) Flickr = flickr(db) FBUsers = fb_user(db) Badge = badge(db) migrate = Migrate(app, db) manager = Manager(app) manager.add_command('db', MigrateCommand) CORS(app) # Initialize facebook class fb = None fpx = _500px(configs['500px_consumer_key'])
# (defaults to read-only item access). ITEM_METHODS = ["GET", "PUT", "PATCH", "DELETE"] # We enable standard client cache directives for all resources exposed by the # API. We can always override these global settings later. CACHE_CONTROL = "max-age=20" CACHE_EXPIRES = 20 X_DOMAINS = "http://*****:*****@gmail.com"}, "license": {"name": "bsd", "url": "https://curriculum.trebuchetclement.fr"}, }, "host": "curriculum.trebuchetclement.fr:5055", } DOMAIN = {"peoples": peoples(), "skills": skills(), "promotions": promotions(), "users": users(), "onions": onions()}
due_date = request.args.get('due_date') return jsonify(todo.api(todo.due_date, date=due_date)) else: return jsonify({"error":"param due_date not provided"}) @ns.route('/over_due') @ns.response(404, 'Opps! page not found') class over_due(Resource): @ns.doc('over_due') def get(self): '''Fetch a given resource''' return jsonify(todo.api(todo.overdue)) @ns.route('/finished') @ns.response(404, 'Opps! page not found') class finished(Resource): @ns.doc('finished') def get(self): '''Fetch a given resource''' return jsonify(todo.api(todo.finished)) if __name__ == "__main__": todo = Todo() user = users() app.secret_key = 'A0Zr98j/3yX R~XHH!jmN]LWX/,?RT' app.run(debug=True)