-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Kurt Garloff <[email protected]>
- Loading branch information
Showing
1 changed file
with
15 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,22 +4,31 @@ | |
# | ||
# (c) Kurt Garloff <[email protected]>, 11/2023 | ||
# SPDX-License-Identifier: CC-BY-SA-4.0 | ||
import os | ||
""" | ||
flavor-form.py | ||
CGI script to get passed flavor from a html form (GET) | ||
and parses it according to SCS flavor naming. | ||
It returns an error (sometimes with a useful error message) | ||
or a human-readable description of the flavor. | ||
""" | ||
|
||
# import os | ||
import sys | ||
import traceback | ||
# import traceback | ||
import cgi | ||
|
||
|
||
def main(argv): | ||
"Entry point for for cgi" | ||
"Entry point for cgi flavor parsing" | ||
import importlib | ||
fnmd = importlib.import_module("flavor-name-describe") | ||
print("Content-Type: text/html\n") | ||
form = cgi.FieldStorage() | ||
try: | ||
fnm = form["flavor"].value | ||
print(f"<h1>SCS flavor name {fnm}</h1>") | ||
pnm = fnmd.main((fnm,)) | ||
except (TypeError,NameError,KeyError) as exc: | ||
fnmd.main((fnm,)) | ||
except (TypeError, NameError, KeyError) as exc: | ||
print("ERROR<br/>") | ||
print(exc) | ||
print('<br/><br/><FORM ACTION="/cgi-bin/flavor-form.py" METHOD="GET">') | ||
|
@@ -29,5 +38,6 @@ def main(argv): | |
print('</FORM>') | ||
print("\n<br/><br/><a href=\"/\">Back to main page</a>") | ||
|
||
|
||
if __name__ == "__main__": | ||
main(sys.argv[1:]) |