commit message from python script
This commit is contained in:
26
create_wireguard_os_simple/default_server.py
Normal file → Executable file
26
create_wireguard_os_simple/default_server.py
Normal file → Executable file
@@ -1 +1,25 @@
|
|||||||
#! /usr/bin/env python3
|
#! /usr/bin/env python3.11
|
||||||
|
import os
|
||||||
|
|
||||||
|
class create_server:
|
||||||
|
def create_config(self):
|
||||||
|
pass
|
||||||
|
def create_unit(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
####Test_block
|
||||||
|
def get_file(name):
|
||||||
|
try:
|
||||||
|
return open(name)
|
||||||
|
except FileNotFoundError as NoFile:
|
||||||
|
print(NoFile.strerror)
|
||||||
|
print("File wird angelegt")
|
||||||
|
return False
|
||||||
|
|
||||||
|
test = get_file(name="test.ymll")
|
||||||
|
print(test)
|
||||||
6
regex_test/main.py
Normal file
6
regex_test/main.py
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
import re
|
||||||
|
|
||||||
|
txt = "The rain in Spain"
|
||||||
|
x = re.search("^The.*Spain$", txt)
|
||||||
|
if x :
|
||||||
|
print("Yes")
|
||||||
31
webserver/main.py
Normal file
31
webserver/main.py
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
#!/ usr / bin / env python3
|
||||||
|
from http.server import BaseHTTPRequestHandler , HTTPServer
|
||||||
|
import os, datetime
|
||||||
|
class myServer ( BaseHTTPRequestHandler ) :
|
||||||
|
def do_GET ( self ) :
|
||||||
|
load = os.getloadavg()
|
||||||
|
html = """<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title> Hello world </title>
|
||||||
|
<meta charset=" utf-8" />
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>Hello world : python </h1>
|
||||||
|
<p> Serverzeit : {now} <br/>
|
||||||
|
Serverauslastung (load) : {load}
|
||||||
|
</body>
|
||||||
|
</html>""". format (now = datetime.datetime.now().astimezone() , load = load [0])
|
||||||
|
|
||||||
|
self.send_response(200)
|
||||||
|
self.send_header( 'Content-type' , 'text/html')
|
||||||
|
self.end_headers()
|
||||||
|
self.wfile.write(bytes (html, "utf8"))
|
||||||
|
return
|
||||||
|
|
||||||
|
def run ():
|
||||||
|
addr = ('',8080)
|
||||||
|
httpd = HTTPServer(addr, myServer)
|
||||||
|
httpd.serve_forever()
|
||||||
|
|
||||||
|
run()
|
||||||
Reference in New Issue
Block a user