Example #1
0
#!C:\Users\SwiftNICK\AppData\Local\Programs\Python\Python38-32\python.exe

import _html
import subject
import os
import cgi
import printTable
import session

params = cgi.FieldStorage()
if (os.environ["REQUEST_METHOD"].upper() == "POST"):
    session.add_to_session(params)
data = session.get_session_data()
print()
_html.start_html()
_html.print_nav()
print('<form action="upisniList.py" method="post">')
subjects = subject.getSubjects()
printTable.printTable(subjects, 3, data)
print('<input type="submit" value="Submit"></form>')

_html.finish_html()
Example #2
0
#!C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\python.exe

import base
import os, cgi
import session
import authentication

params = cgi.FieldStorage()
if (os.environ["REQUEST_METHOD"].upper() == "POST"):
    username = params.getvalue("username")
    password = params.getvalue("password")
    success, user_id = authentication.authenticate(username, password)
    if success:
        session_id = session.create_session()
        session.add_to_session({"user_id": user_id}, session_id=session_id)
        print('Location: upload.py')

print("")
base.start_html()
print('''<form method="POST">
username <input type="text" name="username" />
password <input type="password" name="password"/>
<input type="submit" value="Login"/>
</form>''')
if (os.environ["REQUEST_METHOD"].upper() == "POST" and not success):
    print("<div>Login Error</div>")
base.finish_html()
Example #3
0
#!C:\Users\nikol\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\python.exe
import _html
import os,cgi
import session
import authentication
from http import cookies

params = cgi.FieldStorage()
if (os.environ["REQUEST_METHOD"].upper() == "POST"):
    username = params.getvalue("username")
    password = params.getvalue("password")
    success, user_id = authentication.authenticate(username, password)
    if(success):
        session_id = session.create_session()
        session.add_to_session({"user_id": user_id, "collection_id": 1, "username": username}, session_id=session_id)
        cookies_object = cookies.SimpleCookie()
        cookies_object["username"] = username
        print (cookies_object.output())
        print("Location: index.py")

print("")


_html.start_html()
print ('''<form method="POST">
username <input type="text" name="username" />
password <input type="password" name="password"/>
<input type="submit" value="Login"/>
<a href="register.py">Register</a>
</form>''')
if (os.environ["REQUEST_METHOD"].upper() == "POST" and not success):