Junaidb commited on
Commit
40917a8
·
verified ·
1 Parent(s): 1aff627

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +60 -0
app.py ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastapi import FastAPI,Request,HTTPException,Response
2
+ from pydantic import BaseModel
3
+ from fastapi.responses import JSONResponse
4
+ import uuid
5
+ from fastapi.middleware.cors import CORSMiddleware
6
+ import json
7
+ import base64
8
+ from components.middleware import x401Kit
9
+
10
+
11
+
12
+
13
+
14
+
15
+
16
+
17
+
18
+
19
+
20
+
21
+
22
+
23
+
24
+
25
+ app=FastAPI()
26
+
27
+
28
+
29
+
30
+
31
+ client=provideClient()
32
+ origins=[
33
+ "http://localhost:3000",
34
+ "http://localhost:3001"
35
+ ]
36
+
37
+ app.add_middleware(
38
+ CORSMiddleware,
39
+ allow_origins=origins,
40
+ allow_credentials=True,
41
+ allow_methods=["*"],
42
+ allow_headers=["*"],
43
+ )
44
+
45
+
46
+
47
+
48
+ app.add_middleware(
49
+ x401Kit,
50
+ protected_paths=[
51
+ "/x401_auth"
52
+ ]
53
+ )
54
+
55
+
56
+
57
+ @app.get("/x401_auth")
58
+ def Auth401(request:Request):
59
+ return {"address":""}
60
+