nsarrazin HF staff commited on
Commit
3583f72
1 Parent(s): 0d04ccb

initial push

Browse files
Files changed (5) hide show
  1. .gitignore +1 -0
  2. Dockerfile +11 -0
  3. README.md +1 -0
  4. main.py +273 -0
  5. requirements.txt +2 -0
.gitignore ADDED
@@ -0,0 +1 @@
 
 
1
+ __pycache__
Dockerfile ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.9
2
+
3
+ WORKDIR /code
4
+
5
+ COPY ./requirements.txt /code/requirements.txt
6
+
7
+ RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
8
+
9
+ COPY . .
10
+
11
+ CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"]
README.md CHANGED
@@ -5,6 +5,7 @@ colorFrom: purple
5
  colorTo: gray
6
  sdk: docker
7
  pinned: false
 
8
  ---
9
 
10
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
5
  colorTo: gray
6
  sdk: docker
7
  pinned: false
8
+ port: 7860
9
  ---
10
 
11
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
main.py ADDED
@@ -0,0 +1,273 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # get current date (not time)
2
+ # seed a random generator from it
3
+ # pick a country from the list and return it
4
+
5
+ import random
6
+ import datetime
7
+ from fastapi import FastAPI
8
+ from fastapi.responses import JSONResponse
9
+
10
+ app = FastAPI()
11
+
12
+ countries = [
13
+ {"Name": "Afghanistan", "Code": "AF"},
14
+ {"Name": "Albania", "Code": "AL"},
15
+ {"Name": "Algeria", "Code": "DZ"},
16
+ {"Name": "American Samoa", "Code": "AS"},
17
+ {"Name": "Andorra", "Code": "AD"},
18
+ {"Name": "Angola", "Code": "AO"},
19
+ {"Name": "Anguilla", "Code": "AI"},
20
+ {"Name": "Antarctica", "Code": "AQ"},
21
+ {"Name": "Antigua and Barbuda", "Code": "AG"},
22
+ {"Name": "Argentina", "Code": "AR"},
23
+ {"Name": "Armenia", "Code": "AM"},
24
+ {"Name": "Aruba", "Code": "AW"},
25
+ {"Name": "Australia", "Code": "AU"},
26
+ {"Name": "Austria", "Code": "AT"},
27
+ {"Name": "Azerbaijan", "Code": "AZ"},
28
+ {"Name": "Bahamas", "Code": "BS"},
29
+ {"Name": "Bahrain", "Code": "BH"},
30
+ {"Name": "Bangladesh", "Code": "BD"},
31
+ {"Name": "Barbados", "Code": "BB"},
32
+ {"Name": "Belarus", "Code": "BY"},
33
+ {"Name": "Belgium", "Code": "BE"},
34
+ {"Name": "Belize", "Code": "BZ"},
35
+ {"Name": "Benin", "Code": "BJ"},
36
+ {"Name": "Bermuda", "Code": "BM"},
37
+ {"Name": "Bhutan", "Code": "BT"},
38
+ {"Name": "Bolivia, Plurinational State of", "Code": "BO"},
39
+ {"Name": "Bonaire, Sint Eustatius and Saba", "Code": "BQ"},
40
+ {"Name": "Bosnia and Herzegovina", "Code": "BA"},
41
+ {"Name": "Botswana", "Code": "BW"},
42
+ {"Name": "Bouvet Island", "Code": "BV"},
43
+ {"Name": "Brazil", "Code": "BR"},
44
+ {"Name": "British Indian Ocean Territory", "Code": "IO"},
45
+ {"Name": "Brunei Darussalam", "Code": "BN"},
46
+ {"Name": "Bulgaria", "Code": "BG"},
47
+ {"Name": "Burkina Faso", "Code": "BF"},
48
+ {"Name": "Burundi", "Code": "BI"},
49
+ {"Name": "Cambodia", "Code": "KH"},
50
+ {"Name": "Cameroon", "Code": "CM"},
51
+ {"Name": "Canada", "Code": "CA"},
52
+ {"Name": "Cape Verde", "Code": "CV"},
53
+ {"Name": "Cayman Islands", "Code": "KY"},
54
+ {"Name": "Central African Republic", "Code": "CF"},
55
+ {"Name": "Chad", "Code": "TD"},
56
+ {"Name": "Chile", "Code": "CL"},
57
+ {"Name": "China", "Code": "CN"},
58
+ {"Name": "Christmas Island", "Code": "CX"},
59
+ {"Name": "Cocos (Keeling) Islands", "Code": "CC"},
60
+ {"Name": "Colombia", "Code": "CO"},
61
+ {"Name": "Comoros", "Code": "KM"},
62
+ {"Name": "Congo", "Code": "CG"},
63
+ {"Name": "Congo, the Democratic Republic of the", "Code": "CD"},
64
+ {"Name": "Cook Islands", "Code": "CK"},
65
+ {"Name": "Costa Rica", "Code": "CR"},
66
+ {"Name": "Croatia", "Code": "HR"},
67
+ {"Name": "Cuba", "Code": "CU"},
68
+ {"Name": "Curaçao", "Code": "CW"},
69
+ {"Name": "Cyprus", "Code": "CY"},
70
+ {"Name": "Czech Republic", "Code": "CZ"},
71
+ {"Name": "Côte d'Ivoire", "Code": "CI"},
72
+ {"Name": "Denmark", "Code": "DK"},
73
+ {"Name": "Djibouti", "Code": "DJ"},
74
+ {"Name": "Dominica", "Code": "DM"},
75
+ {"Name": "Dominican Republic", "Code": "DO"},
76
+ {"Name": "Ecuador", "Code": "EC"},
77
+ {"Name": "Egypt", "Code": "EG"},
78
+ {"Name": "El Salvador", "Code": "SV"},
79
+ {"Name": "Equatorial Guinea", "Code": "GQ"},
80
+ {"Name": "Eritrea", "Code": "ER"},
81
+ {"Name": "Estonia", "Code": "EE"},
82
+ {"Name": "Ethiopia", "Code": "ET"},
83
+ {"Name": "Falkland Islands (Malvinas)", "Code": "FK"},
84
+ {"Name": "Faroe Islands", "Code": "FO"},
85
+ {"Name": "Fiji", "Code": "FJ"},
86
+ {"Name": "Finland", "Code": "FI"},
87
+ {"Name": "France", "Code": "FR"},
88
+ {"Name": "French Guiana", "Code": "GF"},
89
+ {"Name": "French Polynesia", "Code": "PF"},
90
+ {"Name": "French Southern Territories", "Code": "TF"},
91
+ {"Name": "Gabon", "Code": "GA"},
92
+ {"Name": "Gambia", "Code": "GM"},
93
+ {"Name": "Georgia", "Code": "GE"},
94
+ {"Name": "Germany", "Code": "DE"},
95
+ {"Name": "Ghana", "Code": "GH"},
96
+ {"Name": "Gibraltar", "Code": "GI"},
97
+ {"Name": "Greece", "Code": "GR"},
98
+ {"Name": "Greenland", "Code": "GL"},
99
+ {"Name": "Grenada", "Code": "GD"},
100
+ {"Name": "Guadeloupe", "Code": "GP"},
101
+ {"Name": "Guam", "Code": "GU"},
102
+ {"Name": "Guatemala", "Code": "GT"},
103
+ {"Name": "Guernsey", "Code": "GG"},
104
+ {"Name": "Guinea", "Code": "GN"},
105
+ {"Name": "Guinea-Bissau", "Code": "GW"},
106
+ {"Name": "Guyana", "Code": "GY"},
107
+ {"Name": "Haiti", "Code": "HT"},
108
+ {"Name": "Heard Island and McDonald Islands", "Code": "HM"},
109
+ {"Name": "Holy See (Vatican City State)", "Code": "VA"},
110
+ {"Name": "Honduras", "Code": "HN"},
111
+ {"Name": "Hong Kong", "Code": "HK"},
112
+ {"Name": "Hungary", "Code": "HU"},
113
+ {"Name": "Iceland", "Code": "IS"},
114
+ {"Name": "India", "Code": "IN"},
115
+ {"Name": "Indonesia", "Code": "ID"},
116
+ {"Name": "Iran, Islamic Republic of", "Code": "IR"},
117
+ {"Name": "Iraq", "Code": "IQ"},
118
+ {"Name": "Ireland", "Code": "IE"},
119
+ {"Name": "Isle of Man", "Code": "IM"},
120
+ {"Name": "Israel", "Code": "IL"},
121
+ {"Name": "Italy", "Code": "IT"},
122
+ {"Name": "Jamaica", "Code": "JM"},
123
+ {"Name": "Japan", "Code": "JP"},
124
+ {"Name": "Jersey", "Code": "JE"},
125
+ {"Name": "Jordan", "Code": "JO"},
126
+ {"Name": "Kazakhstan", "Code": "KZ"},
127
+ {"Name": "Kenya", "Code": "KE"},
128
+ {"Name": "Kiribati", "Code": "KI"},
129
+ {"Name": "Korea, Democratic People's Republic of", "Code": "KP"},
130
+ {"Name": "Korea, Republic of", "Code": "KR"},
131
+ {"Name": "Kuwait", "Code": "KW"},
132
+ {"Name": "Kyrgyzstan", "Code": "KG"},
133
+ {"Name": "Lao People's Democratic Republic", "Code": "LA"},
134
+ {"Name": "Latvia", "Code": "LV"},
135
+ {"Name": "Lebanon", "Code": "LB"},
136
+ {"Name": "Lesotho", "Code": "LS"},
137
+ {"Name": "Liberia", "Code": "LR"},
138
+ {"Name": "Libya", "Code": "LY"},
139
+ {"Name": "Liechtenstein", "Code": "LI"},
140
+ {"Name": "Lithuania", "Code": "LT"},
141
+ {"Name": "Luxembourg", "Code": "LU"},
142
+ {"Name": "Macao", "Code": "MO"},
143
+ {"Name": "Macedonia, the Former Yugoslav Republic of", "Code": "MK"},
144
+ {"Name": "Madagascar", "Code": "MG"},
145
+ {"Name": "Malawi", "Code": "MW"},
146
+ {"Name": "Malaysia", "Code": "MY"},
147
+ {"Name": "Maldives", "Code": "MV"},
148
+ {"Name": "Mali", "Code": "ML"},
149
+ {"Name": "Malta", "Code": "MT"},
150
+ {"Name": "Marshall Islands", "Code": "MH"},
151
+ {"Name": "Martinique", "Code": "MQ"},
152
+ {"Name": "Mauritania", "Code": "MR"},
153
+ {"Name": "Mauritius", "Code": "MU"},
154
+ {"Name": "Mayotte", "Code": "YT"},
155
+ {"Name": "Mexico", "Code": "MX"},
156
+ {"Name": "Micronesia, Federated States of", "Code": "FM"},
157
+ {"Name": "Moldova, Republic of", "Code": "MD"},
158
+ {"Name": "Monaco", "Code": "MC"},
159
+ {"Name": "Mongolia", "Code": "MN"},
160
+ {"Name": "Montenegro", "Code": "ME"},
161
+ {"Name": "Montserrat", "Code": "MS"},
162
+ {"Name": "Morocco", "Code": "MA"},
163
+ {"Name": "Mozambique", "Code": "MZ"},
164
+ {"Name": "Myanmar", "Code": "MM"},
165
+ {"Name": "Namibia", "Code": "NA"},
166
+ {"Name": "Nauru", "Code": "NR"},
167
+ {"Name": "Nepal", "Code": "NP"},
168
+ {"Name": "Netherlands", "Code": "NL"},
169
+ {"Name": "New Caledonia", "Code": "NC"},
170
+ {"Name": "New Zealand", "Code": "NZ"},
171
+ {"Name": "Nicaragua", "Code": "NI"},
172
+ {"Name": "Niger", "Code": "NE"},
173
+ {"Name": "Nigeria", "Code": "NG"},
174
+ {"Name": "Niue", "Code": "NU"},
175
+ {"Name": "Norfolk Island", "Code": "NF"},
176
+ {"Name": "Northern Mariana Islands", "Code": "MP"},
177
+ {"Name": "Norway", "Code": "NO"},
178
+ {"Name": "Oman", "Code": "OM"},
179
+ {"Name": "Pakistan", "Code": "PK"},
180
+ {"Name": "Palau", "Code": "PW"},
181
+ {"Name": "Palestine, State of", "Code": "PS"},
182
+ {"Name": "Panama", "Code": "PA"},
183
+ {"Name": "Papua New Guinea", "Code": "PG"},
184
+ {"Name": "Paraguay", "Code": "PY"},
185
+ {"Name": "Peru", "Code": "PE"},
186
+ {"Name": "Philippines", "Code": "PH"},
187
+ {"Name": "Pitcairn", "Code": "PN"},
188
+ {"Name": "Poland", "Code": "PL"},
189
+ {"Name": "Portugal", "Code": "PT"},
190
+ {"Name": "Puerto Rico", "Code": "PR"},
191
+ {"Name": "Qatar", "Code": "QA"},
192
+ {"Name": "Romania", "Code": "RO"},
193
+ {"Name": "Russian Federation", "Code": "RU"},
194
+ {"Name": "Rwanda", "Code": "RW"},
195
+ {"Name": "Réunion", "Code": "RE"},
196
+ {"Name": "Saint Barthélemy", "Code": "BL"},
197
+ {"Name": "Saint Helena, Ascension and Tristan da Cunha", "Code": "SH"},
198
+ {"Name": "Saint Kitts and Nevis", "Code": "KN"},
199
+ {"Name": "Saint Lucia", "Code": "LC"},
200
+ {"Name": "Saint Martin (French part)", "Code": "MF"},
201
+ {"Name": "Saint Pierre and Miquelon", "Code": "PM"},
202
+ {"Name": "Saint Vincent and the Grenadines", "Code": "VC"},
203
+ {"Name": "Samoa", "Code": "WS"},
204
+ {"Name": "San Marino", "Code": "SM"},
205
+ {"Name": "Sao Tome and Principe", "Code": "ST"},
206
+ {"Name": "Saudi Arabia", "Code": "SA"},
207
+ {"Name": "Senegal", "Code": "SN"},
208
+ {"Name": "Serbia", "Code": "RS"},
209
+ {"Name": "Seychelles", "Code": "SC"},
210
+ {"Name": "Sierra Leone", "Code": "SL"},
211
+ {"Name": "Singapore", "Code": "SG"},
212
+ {"Name": "Sint Maarten (Dutch part)", "Code": "SX"},
213
+ {"Name": "Slovakia", "Code": "SK"},
214
+ {"Name": "Slovenia", "Code": "SI"},
215
+ {"Name": "Solomon Islands", "Code": "SB"},
216
+ {"Name": "Somalia", "Code": "SO"},
217
+ {"Name": "South Africa", "Code": "ZA"},
218
+ {"Name": "South Georgia and the South Sandwich Islands", "Code": "GS"},
219
+ {"Name": "South Sudan", "Code": "SS"},
220
+ {"Name": "Spain", "Code": "ES"},
221
+ {"Name": "Sri Lanka", "Code": "LK"},
222
+ {"Name": "Sudan", "Code": "SD"},
223
+ {"Name": "Suriname", "Code": "SR"},
224
+ {"Name": "Svalbard and Jan Mayen", "Code": "SJ"},
225
+ {"Name": "Swaziland", "Code": "SZ"},
226
+ {"Name": "Sweden", "Code": "SE"},
227
+ {"Name": "Switzerland", "Code": "CH"},
228
+ {"Name": "Syrian Arab Republic", "Code": "SY"},
229
+ {"Name": "Taiwan, Province of China", "Code": "TW"},
230
+ {"Name": "Tajikistan", "Code": "TJ"},
231
+ {"Name": "Tanzania, United Republic of", "Code": "TZ"},
232
+ {"Name": "Thailand", "Code": "TH"},
233
+ {"Name": "Timor-Leste", "Code": "TL"},
234
+ {"Name": "Togo", "Code": "TG"},
235
+ {"Name": "Tokelau", "Code": "TK"},
236
+ {"Name": "Tonga", "Code": "TO"},
237
+ {"Name": "Trinidad and Tobago", "Code": "TT"},
238
+ {"Name": "Tunisia", "Code": "TN"},
239
+ {"Name": "Turkey", "Code": "TR"},
240
+ {"Name": "Turkmenistan", "Code": "TM"},
241
+ {"Name": "Turks and Caicos Islands", "Code": "TC"},
242
+ {"Name": "Tuvalu", "Code": "TV"},
243
+ {"Name": "Uganda", "Code": "UG"},
244
+ {"Name": "Ukraine", "Code": "UA"},
245
+ {"Name": "United Arab Emirates", "Code": "AE"},
246
+ {"Name": "United Kingdom", "Code": "GB"},
247
+ {"Name": "United States", "Code": "US"},
248
+ {"Name": "United States Minor Outlying Islands", "Code": "UM"},
249
+ {"Name": "Uruguay", "Code": "UY"},
250
+ {"Name": "Uzbekistan", "Code": "UZ"},
251
+ {"Name": "Vanuatu", "Code": "VU"},
252
+ {"Name": "Venezuela, Bolivarian Republic of", "Code": "VE"},
253
+ {"Name": "Viet Nam", "Code": "VN"},
254
+ {"Name": "Virgin Islands, British", "Code": "VG"},
255
+ {"Name": "Virgin Islands, U.S.", "Code": "VI"},
256
+ {"Name": "Wallis and Futuna", "Code": "WF"},
257
+ {"Name": "Western Sahara", "Code": "EH"},
258
+ {"Name": "Yemen", "Code": "YE"},
259
+ {"Name": "Zambia", "Code": "ZM"},
260
+ {"Name": "Zimbabwe", "Code": "ZW"},
261
+ {"Name": "Åland Islands", "Code": "AX"},
262
+ ]
263
+
264
+
265
+ @app.get("/")
266
+ async def read_root():
267
+ return {"message": "Hello World"}
268
+
269
+
270
+ @app.get("/random")
271
+ async def read_random():
272
+ random.seed(datetime.date.today().isoformat())
273
+ return "The country of the day is: **" + random.choice(countries)["Name"] + "**"
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ fastapi
2
+ uvicorn