bradley6597 commited on
Commit
e54af7b
1 Parent(s): a1620bf

Removed Starlette dependency

Browse files
Files changed (1) hide show
  1. app.py +55 -5
app.py CHANGED
@@ -1,3 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
 
2
  logger = gr.HuggingFaceDatasetSaver(os.environ['HUB_TOKEN'], dataset_name='illustration_gdrive_logging', organization=None, private=True)
3
  logger.setup([gr.Text(label="clicked_url"), gr.Text(label="seach_term"), gr.Text(label = 'sessionhash'), gr.Text(label = 'datetime')], './flagged_data_points')
@@ -12,7 +24,7 @@ function magicFunc(x){
12
  '''
13
 
14
 
15
- ill_links = pd.read_csv("./data/data.csv").drop_duplicates()
16
  ill_links = ill_links[ill_links['Description'] != 'Moved'].copy()
17
  ill_links['code'] = ill_links['link'].str.replace("https://drive.google.com/file/d/", "", regex = False)
18
  ill_links['code'] = ill_links['code'].str.replace("/view?usp=drivesdk", "", regex = False)
@@ -152,11 +164,49 @@ with gr.Blocks(css="style.css") as app:
152
  search_prompt.submit(search_logging, inputs=[search_prompt, search_prompt], outputs=None, api_name='track')
153
  app.load(_js = logging_js)
154
 
155
- # app.auth = (same_auth)
156
- # app.auth_message = ''
157
 
158
  app.launch(debug=True,
159
  share=False,
160
  height=768,
161
- auth=(same_auth)
162
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import functions as funky
2
+ import pandas as pd
3
+ import gradio as gr
4
+ import numpy as np
5
+ from datetime import datetime
6
+
7
+ from datasets import load_dataset
8
+ from huggingface_hub import login
9
+
10
+ login(token = os.environ['HUB_TOKEN'])
11
+ dataset = load_dataset("bradley6597/illustration-test")
12
+ df = pd.DataFrame(dataset['train'])
13
 
14
  logger = gr.HuggingFaceDatasetSaver(os.environ['HUB_TOKEN'], dataset_name='illustration_gdrive_logging', organization=None, private=True)
15
  logger.setup([gr.Text(label="clicked_url"), gr.Text(label="seach_term"), gr.Text(label = 'sessionhash'), gr.Text(label = 'datetime')], './flagged_data_points')
 
24
  '''
25
 
26
 
27
+ ill_links = df
28
  ill_links = ill_links[ill_links['Description'] != 'Moved'].copy()
29
  ill_links['code'] = ill_links['link'].str.replace("https://drive.google.com/file/d/", "", regex = False)
30
  ill_links['code'] = ill_links['code'].str.replace("/view?usp=drivesdk", "", regex = False)
 
164
  search_prompt.submit(search_logging, inputs=[search_prompt, search_prompt], outputs=None, api_name='track')
165
  app.load(_js = logging_js)
166
 
167
+ app.auth = (same_auth)
168
+ app.auth_message = ''
169
 
170
  app.launch(debug=True,
171
  share=False,
172
  height=768,
173
+ # auth=("twinkl", "twinkl432!")
174
+ )
175
+
176
+ # app.close()
177
+
178
+ # from fastapi import FastAPI, Request
179
+ # import uvicorn
180
+ # from starlette.middleware.sessions import SessionMiddleware
181
+ # fapi = FastAPI()
182
+
183
+ # fapi.add_middleware(SessionMiddleware, secret_key=os.environ['session_key'])
184
+
185
+ # @fapi.middleware("http")
186
+ # async def add_session_hash(request: Request, call_next):
187
+ # response = await call_next(request)
188
+ # session = request.cookies.get('session')
189
+ # if session:
190
+ # response.set_cookie(key='session', value=request.cookies.get('session'), httponly=True)
191
+ # return response
192
+
193
+ # # custom get request handler with params to flag clicks
194
+ # @ fapi.get("/track")
195
+ # async def track(url: str, q: str, request: Request):
196
+
197
+ # print(request)
198
+ # if q is None:
199
+ # q = ''
200
+
201
+ # logger.flag([url, q, request.cookies['access-token'], str(datetime.now())])
202
+ # return {"message": "ok"}
203
+
204
+
205
+
206
+ # logger.flag(['test', 'test', 'test', str(datetime.now())])
207
+
208
+ # # mount Gradio app to FastAPI app
209
+ # app2 = gr.mount_gradio_app(fapi, app, path="/")
210
+ # # serve the app
211
+ # if __name__ == "__main__":
212
+ # uvicorn.run(app2, host="0.0.0.0", port=7860)