File tree 3 files changed +37
-8
lines changed
3 files changed +37
-8
lines changed Original file line number Diff line number Diff line change @@ -27,6 +27,17 @@ def logout():
27
27
session .pop (d , None )
28
28
return redirect (url_for ('index' ))
29
29
30
+ @app .route ('/api-auth-test' )
31
+ def apitestauth ():
32
+ data = {
33
+ "test" : 'no'
34
+ }
35
+ if session ['username' ]:
36
+ data = {
37
+ "test" : session ['username' ]
38
+ }
39
+ return data
40
+
30
41
@app .route ('/test-auth' ,methods = ['GET' ,'POST' ])
31
42
def auth ():
32
43
if session ['username' ]== 'harsh' :
Original file line number Diff line number Diff line change
1
+ async function main ( ) {
2
+ var url = "localhost:5000/api-auth-test" ;
3
+ const response = await fetch ( url ) ;
4
+ var data = await response . json ( ) ;
5
+ document . getElementById ( "size" ) . innerHTML = "test = " + data [ 'test' ] ;
6
+ console . log ( data ) ;
7
+ }
Original file line number Diff line number Diff line change 4
4
< title > Cloud Desktop</ title >
5
5
</ head >
6
6
< body >
7
+ < script >
8
+ async function main ( ) {
9
+ var url = "http://localhost:5000/api-auth-test" ;
10
+ const response = await fetch ( url ) ;
11
+ var data = await response . json ( ) ;
12
+ document . getElementById ( "test" ) . innerHTML = "test = " + data [ 'test' ] ;
13
+ console . log ( data ) ;
14
+ }
15
+ </ script >
7
16
8
- < h1 > Welcome to Cloud Desktop</ h1 >
9
- < a href ="/login "> < h2 > Login to Continue</ h2 > </ a >
17
+ < h1 > Welcome to Cloud Desktop</ h1 >
18
+ < a href ="/login "> < h2 > Login to Continue</ h2 > </ a >
10
19
11
- < form action = "login " method = "post ">
12
- < p > username : < input type = text name = username > </ p >
13
- < p > password : < input type = text name = password > </ p >
14
- < p > < input type = submit value = Login > </ p >
15
- </ form >
16
-
20
+ < form action = "login " method = "post ">
21
+ < p > username : < input type = text name = username > </ p >
22
+ < p > password : < input type = text name = password > </ p >
23
+ < p > < input type = submit value = Login > </ p >
24
+ </ form >
25
+
26
+ < button onclick ="main() "> test</ button >
27
+ < h3 id ="test "> Loading </ h3 >
17
28
18
29
</ body >
19
30
</ html >
You can’t perform that action at this time.
0 commit comments