-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.py
79 lines (57 loc) · 2.24 KB
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# app.py
from ridaakh.api import Ridaakh
from DB.sample2 import new_user
# from ridaakh.forms import fields, forms, widgets
# from wtforms import Form,StringField, PasswordField, validators
# from wtforms.validators import InputRequired
app = Ridaakh()
# inpp = widgets
@app.route("/")
def home(req, resp):
# resp.text = "Hello, this is a home page."
name= new_user.name
fullname= new_user.fullname
nickname= new_user.nickname
success= "You have successfully installed"
welcome= "You are seeing this page because you have not configured any root.\
Move to app.py and customize the route according to your needs.\
To find more information visit our documentation page."
inp= inpp.TextInput()
resp.html = app.template("home.html",context={"title": "Awesome Framework",
"name": name, "fullname": fullname, "nickname": nickname, "success": success, })
# class LoginForm(Form):
# #username= StringField('username', validators= [validators.input_required()])
# #password= PasswordField('password', validators= [validators.input_required()])
# username= StringField('username')
# password= PasswordField('password')
# #
# @app.route("/about", methods=['GET', 'POST'])
# def about_page(req, resp):
# form= LoginForm()
# if (form.validate()):
# resp.text = "successfully submitted!"
#
# resp.html = app.template("about.html", context={"name": "ridaakh", 'form': form})
#
@app.route("/about")
def about_page(req, resp):
name= "ridaakh Web Framework"
about= "This text should contain about page's content."
resp.html = app.template("about.html", context={"name": name, "about": about })
@app.route("/{age:d}")
def tell_age(req, resp, age):
resp.text = f"Your age is {age}"
@app.route("/{name:l}")
class GreetingHandler:
def get(self, req, resp, name):
resp.text = f"Hello, {name}"
@app.route("/show/template")
def handler_with_template(req, resp):
resp.html = app.template("example.html", context={"title": "Awesome Framework", "body": "welcome to the future!"})
@app.route("/json")
def json_handler(req, resp):
resp.json = {"this": "is JSON",}
@app.route("/custom")
def custom_response(req, resp):
resp.body = b'any other body'
resp.content_type = "text/plain"