Python/CGI

From Soyjak Wiki, the free ensoyclopedia
Jump to navigationJump to search
This is actually... helpful?

You can read this for more info about the topic

This page is a subsection of Python.

Python CGI is a way of making web apps (such as...) in Python using CGI. Firstly, install CGI by running pip install legacy-cgi. Then, if you are using xampp, go to C:/xampp/cgi-bin and make a new python file, e.g. test.py, enter this to get you started This is for Windows, i will put a Linux version here soon. Also, Change "Admin" and "Python313" to your username/python version! this article has been edited to be for linux now (meds, python is literally cross platform, you just run it directly on the python interpreter (meds, you see that little #! line? that's the shebang for Python, and it's different for Windows and Linux)

Webpage example[edit | edit source]

#!/usr/bin/env python3
import random

from typing import List

SOYJAKS: List[str] = ["cobson", "schizo hallucination soyjak", "scary markiplier speaking with widened eyes and background"]

def random_boolean() -> bool:
    """
    @brief Has an equal probability of returning either True or False.
    
    @return True or False with equal probability
    """
    return random.choice([True, False])

if __name__ == "__main__":
    print("Content-Type: text/html")
    print("")

    print('<!DOCTYPE html><html><head><title>soy python cgi</title></head><body>')
    print(f'    <p>You are a {random.choice(SOYJAKS)}</p>')
    print(f'    <p>Retard: {random_boolean()}, Nigger: {random_boolean()}.</p>')
    print('</body></html>')

API example[edit | edit source]

#!/usr/bin/env python3
import random

from typing import List

SOYJAKS: List[str] = ["cobson", "schizo hallucination soyjak", "scary markiplier speaking with widened eyes and background"]

def random_boolean() -> bool:
    """
    @brief Has an equal probability of returning either True or False.
    
    @return True or False with equal probability
    """
    return random.choice([True, False])

if __name__ == "__main__":
    print("Content-Type: text/xml")
    print("")

    print('<?xml version="1.0" encoding="UTF-8"?>')
    print('<api>')
    print(f'    <soyjak>{random.choice(SOYJAKS)}</soyjak>')
    print(f'    <retard>{random_boolean()}</retard>')
    print(f'    <nigger>{random_boolean()}</nigger>')
    print('</api>')


Python/CGI
is part of a series on
Soyience™

Visit the Soyence portal for more.
"We are all just hecking star dust or something!"
Peer reviewed sources [-+]
Fields of science [-+]
Science in praxis [-+]
Theoretical branches [-+]