コード例 #1
0
#!/usr/bin/python3

import Helpers.db as db
import Helpers.structure as structure
import Helpers.nav as nav
import Helpers.myparser as parser
import os, sys
import Helpers.validator as validator

print("Content-Type: text/html\r\n\r\n")
db.connectDB()
cookie = parser.parseCookie(os.getenv("HTTP_COOKIE"))
autenticate = db.checkSession(parser.parseCookie(
    os.getenv("HTTP_COOKIE"))) if validator.validateSession(cookie) else None

structure.printStartSection()
if autenticate != None:
    nav.printNav(autenticate, db.cartCount(autenticate))
else:
    nav.printNav(autenticate)
structure.printSearchForm()
items = db.getAllItems()
structure.printItemContents(items, 1)
structure.printEndSection()
コード例 #2
0
ファイル: register.py プロジェクト: asolanop/security_ec_shop
		<input id="address" name="address" maxlength="50" />
		<br />
		<label for="telephone">Phone*: </label>
		<br />
		<input id="telephone" name="telephone" maxlength="10" type="number" />
		<br />
		<button>Submit</button>
	</form>
	</div>
</div>"""

if os.getenv("REQUEST_METHOD") == 'GET':
    print("Content-Type: text/html")
    print()
    structure.printStartSection()
    nav.printNav(None)
    print(form)

if os.getenv("REQUEST_METHOD") == 'POST':
    post_params = sys.stdin.read()
    user = parser.parseData(post_params)
    print("Content-Type: text/html")
    print()
    structure.printStartSection()
    nav.printNav(None)
    result = validator.validateUser(user)
    if result == True:
        db.connectDB()
        db.insertUser("id", user['firstname'], user['lastname'], user['email'],
                      user['password'], user['username'], user['telephone'],
                      user['address'])