Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
2.0.1
  • Loading branch information
kerem3338 authored Jan 1, 2022
1 parent d0393ed commit a5f97b7
Showing 1 changed file with 20 additions and 21 deletions.
41 changes: 20 additions & 21 deletions sabe.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,19 @@
from colorama import init
from termcolor import colored
import webbrowser
import flask
from waitress import serve
init()



class Sabe:
"""Sabe web uygulamarını daha kolay ve hızlı şekilde yapabilmek için yazılmıştır"""

def __init__(self):
self.app = Flask(__name__)
self.route_list = []
self.url_list = []
self.version = "2.0"

self.version = "2.0.1"

def info(self):
print("Sabe © Kerem ata\n\nSabe kolay web sitesi oluşturmak için yazılmış bir frameworkdür\nTemelinde flask bulunmaktadır")
Expand All @@ -23,16 +24,19 @@ def version(self):
"""return version"""
return self.version


def render_website(self, url):
def render_website(self, route, url):
"""get file content render content (cannot get css or js file(s))"""
try:
import requests
except:
print(colored("requests modülü bulunamadı", "red"))
try:
url = requests.get(url)
return url.text

@self.app.route(route)
def page():
return url.text

self.url_list.append(url)
except requests.exceptions.MissingSchema:
#print(colored(f"Geçersiz Url: Bunu mu demek istedinizi? (https://{url})", "red"))
Expand All @@ -42,6 +46,7 @@ def render_website(self, url):
def url_routes(self):
"""return all websites urls"""
return(self.url_routes)

def routes(self):
"""return all routes"""
return(self.route_list)
Expand All @@ -50,7 +55,6 @@ def route(self, route, code):
"""add route for application"""
self.route_list.append(route)


@self.app.route(route)
def page():
return code
Expand All @@ -61,6 +65,10 @@ def error_page_add(self, error_code, code):
@self.app.errorhandler(404)
def not_found(e):
return code
elif error_code == "500":
@self.app.errorhandler(500)
def server_error(e):
return code
else:
print(colored(f"Hata kodu {error_code} bulunamadı", "red"))

Expand All @@ -69,20 +77,11 @@ def render_file(self, filename, encoding="utf8"):
with open(filename, encoding=encoding) as filecontant:
return filecontant.read()


def run(self, run="classic"):
def run(self):
"""Run application"""
if run == "classic":
if __name__ == "__main__":
self.app.run()
elif run == "auto":
if __name__ == "__main__":
self.app.run()
webbrowser.open("http://127.0.0.1:5000/")
else:
print("Tanımlanmayan mod")



self.app.run()

def __str__(self):
return "<Sabe>"


0 comments on commit a5f97b7

Please sign in to comment.