-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
executable file
·198 lines (137 loc) · 4.46 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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
from flask import Flask, render_template, url_for, redirect, send_file
from flask_misaka import Misaka
import json
import os
import datetime
import sentry_sdk
from sentry_sdk.integrations.flask import FlaskIntegration
sentry_sdk.init(
dsn="https://4ca333b6023a4503a94b63b58f1b775c@o391718.ingest.sentry.io/5238246",
integrations=[FlaskIntegration()],
)
app = Flask(__name__, static_folder="./assets", static_url_path="/static")
Misaka(app)
if __name__ == "main":
app.run(host="0.0.0.0")
@app.route("/")
def home():
greetings = generateGreetings()
projects = getProjects()
films = getFilms()
works = getWorks()
publications = getPublications()
return render_template(
"index.html",
greetings=greetings,
projects=projects,
films=films,
works=works,
publications=publications,
)
@app.route("/saumi")
def saumi():
return render_template("saumi.html")
@app.route("/afort")
def afort():
return redirect("https://harshitgarg.pythonanywhere.com")
# return ("<html><body>AFORT is currently not available to the general public. If you have any queries, mail at: <em>f20180218@pilani.bits-pilani.ac.in</em></body></html>")
@app.route("/quantum")
def quantum():
worksAll = getWorks()
works = []
for work in worksAll:
if "quantum" in work["domain"]:
works.append(work)
updatesAll = getUpdates()
updates = []
for update in updatesAll:
if "quantum" in update["domain"]:
updates.append(update)
projectsAll = getProjects()
projects = []
for project in projectsAll:
if "quantum" in project["tags"]:
projects.append(project)
return render_template(
"quantum.html", works=works, updates=updates, projects=projects
)
@app.route("/quantum/qiskit")
def qiskit():
return redirect("https://github.com/harshitgarg22/quantum")
@app.route("/quantum/q-sharp")
def qsharp():
return redirect("https://github.com/harshitgarg22/QuantumKatas")
@app.route("/quantum/qdn")
def qdn():
return render_template("qdn.html")
@app.route("/cv")
def cv():
return redirect(
"https://drive.google.com/file/d/1XB8XGzbEneOgdMDQe3pRDQ3ssGCTpqFi/view?usp=sharing"
)
@app.route("/resume")
def resume():
# return send_file(os.path.join(".", "assets", "docs", "cv.pdf"))
return redirect(
"https://drive.google.com/file/d/1_onJxlwp7jnhDU2_W7bk41pVfWR4koiD/view?usp=sharing"
)
@app.template_filter("strftime")
def _jinja2_filter_datetime(date, fmt=None):
try:
date = datetime.datetime.strptime(date, "%Y-%m-%d")
return date.strftime("%b %d, %Y")
except TypeError:
print(TypeError)
def getUpdates():
updates = []
with open(os.path.join("assets", "data", "updates.json"), "r") as f:
updates = json.load(f)
return updates
def getWorks():
works = []
with open(os.path.join("assets", "data", "works.json"), "r") as f:
works = json.load(f)
return works
def getFilms():
films = []
with open(os.path.join("assets", "data", "filmData.json"), "r") as f:
films = json.load(f)
return films
def getProjects():
projects = []
with open(os.path.join("assets", "data", "projects.json"), "r") as f:
projects = json.load(f)
return projects
def getPublications():
pubs = []
with open(os.path.join("assets", "data", "publications.json"), "r") as f:
pubs = json.load(f)
return pubs
# def getworks():
# works = []
# works.append(
# {
# "name": "Practice School-1",
# "company": "UST Global, Trivandrum",
# "project_name": "Quantum Distribution Networks",
# "project_begin": "2020-05-18",
# "project_end": "Present",
# "description": 'We are currently studying about the possibilites of migrating the current Public Key Infrastructure to become "Quantum Safe".',
# }
# )
# return works
def generateGreetings():
greetings = {}
DISPLAY_TEXT = '"Hello World!"'
greetings["languages"] = ["JavaScript", "C++", "C", "python", "bash"]
# greetings["headers"] = ["", "#include <iostream>", "#include <stdio.h>", "", ""]
greetings["display_text"] = DISPLAY_TEXT
greetings["commands_prefix"] = [
"console.log(",
"cout<<",
"printf(",
"print(",
"echo ",
]
greetings["commands_suffix"] = [");", ";", ");", ")", ""]
return greetings