@ -0,0 +1,233 @@ | |||
package gq.yigit.mycity; | |||
import android.content.Context; | |||
import android.content.Intent; | |||
import android.graphics.Bitmap; | |||
import android.graphics.BitmapFactory; | |||
import android.location.LocationListener; | |||
import android.net.Uri; | |||
import android.os.Bundle; | |||
import android.support.v4.app.Fragment; | |||
import android.util.Base64; | |||
import android.util.Log; | |||
import android.view.LayoutInflater; | |||
import android.view.View; | |||
import android.view.ViewGroup; | |||
import android.widget.ImageView; | |||
import android.widget.LinearLayout; | |||
import android.widget.TextView; | |||
import com.google.android.gms.common.api.Status; | |||
import com.google.android.gms.maps.*; | |||
import com.google.android.gms.maps.model.LatLng; | |||
import com.google.android.gms.maps.model.MarkerOptions; | |||
import com.google.android.libraries.places.api.Places; | |||
import com.google.android.libraries.places.api.model.Place; | |||
import com.google.android.libraries.places.api.model.RectangularBounds; | |||
import com.google.android.libraries.places.api.net.PlacesClient; | |||
import com.google.android.libraries.places.widget.Autocomplete; | |||
import com.google.android.libraries.places.widget.AutocompleteActivity; | |||
import com.google.android.libraries.places.widget.model.AutocompleteActivityMode; | |||
import gq.yigit.mycity.tools.FileActions; | |||
import gq.yigit.mycity.tools.WebRequest; | |||
import org.json.JSONException; | |||
import org.json.JSONObject; | |||
import java.util.Arrays; | |||
import java.util.HashMap; | |||
import java.util.List; | |||
import static android.app.Activity.RESULT_CANCELED; | |||
import static android.app.Activity.RESULT_OK; | |||
import static gq.yigit.mycity.MainActivity.apikey; | |||
import static gq.yigit.mycity.MainActivity.cntxt; | |||
public class ParkFragment extends Fragment implements WebRequest.responseListener, OnMapReadyCallback { | |||
private OnFragmentInteractionListener mListener; | |||
private ImageView spot_img; | |||
private TextView place_name; | |||
private String url; | |||
private String latitude; | |||
private String longitude; | |||
private double lat_orig; | |||
private double lng_orig; | |||
private GoogleMap map; | |||
MapView mapFragment; | |||
public ParkFragment() { | |||
// Required empty public constructor | |||
} | |||
public static ParkFragment newInstance(String param1, String param2) { | |||
ParkFragment fragment = new ParkFragment(); | |||
Bundle args = new Bundle(); | |||
fragment.setArguments(args); | |||
return fragment; | |||
} | |||
@Override | |||
public void onCreate(Bundle savedInstanceState) { | |||
super.onCreate(savedInstanceState); | |||
} | |||
@Override | |||
public View onCreateView(LayoutInflater inflater, ViewGroup container, | |||
Bundle savedInstanceState) { | |||
View rootView = inflater.inflate(R.layout.fragment_park, container, false); | |||
mapFragment = rootView.findViewById(R.id.spot_loc); | |||
mapFragment.onCreate(savedInstanceState); | |||
spot_img = rootView.findViewById(R.id.spot_img); | |||
LinearLayout search_button = rootView.findViewById(R.id.search_layout_park); | |||
mapFragment.getMapAsync(this); | |||
search_button.setOnClickListener(new View.OnClickListener() { | |||
@Override | |||
public void onClick(View view) { | |||
Places.initialize(getContext(), apikey); | |||
int AUTOCOMPLETE_REQUEST_CODE = 1; | |||
List<Place.Field> fields = Arrays.asList(Place.Field.ID, Place.Field.NAME,Place.Field.LAT_LNG); | |||
Intent intent = new Autocomplete.IntentBuilder( | |||
AutocompleteActivityMode.FULLSCREEN, fields). | |||
setLocationRestriction(RectangularBounds.newInstance(new LatLng(39.7281252,32.4848006),new LatLng(40.061707,32.9889204))) | |||
.build(getContext()); | |||
startActivityForResult(intent, AUTOCOMPLETE_REQUEST_CODE); | |||
} | |||
}); | |||
place_name = rootView.findViewById(R.id.place_name_park); | |||
try { | |||
lat_orig = 39.9127897; | |||
lng_orig = 32.8073577; | |||
}catch (SecurityException e){ | |||
Log.e("[ERROR]","An error occured with location permissions"); | |||
} | |||
return rootView; | |||
} | |||
public void onButtonPressed(Uri uri) { | |||
if (mListener != null) { | |||
mListener.onFragmentInteraction(uri); | |||
} | |||
} | |||
@Override | |||
public void onAttach(Context context) { | |||
super.onAttach(context); | |||
if (context instanceof OnFragmentInteractionListener) { | |||
mListener = (OnFragmentInteractionListener) context; | |||
} else { | |||
throw new RuntimeException(context.toString() | |||
+ " must implement OnFragmentInteractionListener"); | |||
} | |||
} | |||
@Override | |||
public void onActivityResult(int requestCode, int resultCode, Intent data) { | |||
if (requestCode == 1) { | |||
if (resultCode == RESULT_OK) { | |||
Place place = Autocomplete.getPlaceFromIntent(data); | |||
place_name.setText(place.getName()); | |||
FileActions file_manager = new FileActions(); | |||
url = file_manager.readFromFile(cntxt,"server.config").trim(); | |||
WebRequest request = new WebRequest(url + "/parking",true, new HashMap<String, String>(),0); | |||
request.addListener(this); | |||
request.execute(); | |||
} else if (resultCode == AutocompleteActivity.RESULT_ERROR) { | |||
Status status = Autocomplete.getStatusFromIntent(data); | |||
Log.i("[INFO]", status.getStatusMessage()); | |||
} else if (resultCode == RESULT_CANCELED) { | |||
} | |||
} | |||
} | |||
@Override | |||
public void onDetach() { | |||
super.onDetach(); | |||
mListener = null; | |||
} | |||
public interface OnFragmentInteractionListener { | |||
// TODO: Update argument type and name | |||
void onFragmentInteraction(Uri uri); | |||
} | |||
@Override | |||
public void receivedResponse(boolean success, String data, int code){ | |||
if(success){ | |||
try{ | |||
JSONObject spot = new JSONObject(data); | |||
byte[] decodedString = Base64.decode(spot.getString("img"), Base64.DEFAULT); | |||
Bitmap decodedByte = BitmapFactory.decodeByteArray(decodedString, 0, decodedString.length); | |||
spot_img.setImageBitmap(decodedByte); | |||
latitude = spot.getString("lat"); | |||
longitude = spot.getString("lng"); | |||
LatLng spot_loc = new LatLng(Integer.parseInt(latitude), Integer.parseInt(longitude)); | |||
map.addMarker(new MarkerOptions().position(spot_loc).title("Parking Spot")); | |||
LatLng loc = new LatLng(lat_orig, lng_orig); | |||
map.addMarker(new MarkerOptions().position(loc).title("Location")); | |||
map.moveCamera(CameraUpdateFactory.newLatLng(loc)); | |||
}catch(JSONException e){ | |||
Log.e("[ERROR]","Error parsing json from parking service"); | |||
} | |||
} | |||
} | |||
@Override | |||
public void onMapReady(GoogleMap googleMap) { | |||
map = googleMap; | |||
// Add a marker in Sydney, Australia, and move the camera. | |||
} | |||
@Override | |||
public void onResume() { | |||
super.onResume(); | |||
mapFragment.onResume(); | |||
} | |||
@Override | |||
public void onPause() { | |||
super.onPause(); | |||
mapFragment.onPause(); | |||
} | |||
@Override | |||
public void onDestroy() { | |||
super.onDestroy(); | |||
mapFragment.onDestroy(); | |||
} | |||
@Override | |||
public void onLowMemory() { | |||
super.onLowMemory(); | |||
mapFragment.onLowMemory(); | |||
} | |||
} |
@ -1,67 +0,0 @@ | |||
package gq.yigit.mycity; | |||
import android.Manifest; | |||
import android.content.Intent; | |||
import android.content.pm.PackageManager; | |||
import android.net.Uri; | |||
import android.provider.MediaStore; | |||
import android.support.v4.app.ActivityCompat; | |||
import android.support.v4.content.ContextCompat; | |||
import android.support.v7.app.AppCompatActivity; | |||
import android.os.Bundle; | |||
import android.util.Log; | |||
import android.view.View; | |||
import android.widget.Button; | |||
import android.widget.ImageView; | |||
public class TakePhoto extends AppCompatActivity { | |||
private Button takePictureButton; | |||
private ImageView imageView; | |||
@Override | |||
protected void onCreate(Bundle savedInstanceState) { | |||
super.onCreate(savedInstanceState); | |||
setContentView(R.layout.activity_take_photo); | |||
takePictureButton = (Button) findViewById(R.id.button_image); | |||
imageView = (ImageView) findViewById(R.id.imageview); | |||
if (ContextCompat.checkSelfPermission(this, Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) { | |||
takePictureButton.setEnabled(false); | |||
ActivityCompat.requestPermissions(this, new String[] { Manifest.permission.CAMERA, Manifest.permission.WRITE_EXTERNAL_STORAGE }, 0); | |||
} | |||
} | |||
@Override | |||
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) { | |||
if (requestCode == 0) { | |||
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED | |||
&& grantResults[1] == PackageManager.PERMISSION_GRANTED) { | |||
takePictureButton.setEnabled(true); | |||
} | |||
} | |||
} | |||
public void takePicture(View view) { | |||
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); | |||
startActivityForResult(intent, 100); | |||
} | |||
@Override | |||
protected void onActivityResult(int requestCode, int resultCode, Intent data) { | |||
if (requestCode == 100) { | |||
Log.d("[BOOKMARK]","Actvitity resulted"); | |||
if (resultCode == RESULT_OK) { | |||
if (data == null) { | |||
Log.d("[BOOKMARK]","Received image"); | |||
// TODO Do something with the full image stored | |||
// in outputFileUri. Perhaps copying it to the app folder | |||
} | |||
} | |||
} | |||
} | |||
} |
@ -1,29 +0,0 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | |||
xmlns:tools="http://schemas.android.com/tools" | |||
android:layout_width="match_parent" | |||
android:layout_height="match_parent" | |||
android:paddingBottom="@dimen/activity_vertical_margin" | |||
android:paddingLeft="@dimen/activity_horizontal_margin" | |||
android:paddingRight="@dimen/activity_horizontal_margin" | |||
android:paddingTop="@dimen/activity_vertical_margin" | |||
tools:context=".TakePhoto"> | |||
<ImageView | |||
android:id="@+id/imageview" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:layout_centerHorizontal="true" | |||
android:layout_above="@+id/button_image"/> | |||
<Button | |||
android:id="@+id/button_image" | |||
android:layout_width="wrap_content" | |||
android:layout_height="48dp" | |||
android:layout_alignParentBottom="true" | |||
android:layout_centerHorizontal="true" | |||
android:onClick="takePicture" | |||
android:text="Take a picture!"/> | |||
</RelativeLayout> |
@ -0,0 +1,53 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | |||
xmlns:tools="http://schemas.android.com/tools" | |||
android:layout_width="match_parent" | |||
android:layout_height="match_parent" xmlns:app="http://schemas.android.com/apk/res-auto" | |||
tools:context=".ParkFragment" android:layout_marginTop="45dp"> | |||
<LinearLayout | |||
android:orientation="horizontal" | |||
android:layout_width="match_parent" | |||
android:layout_height="wrap_content" android:id="@+id/search_layout_park" | |||
android:background="@drawable/search_shape" | |||
android:layout_marginHorizontal="10dp" | |||
android:paddingHorizontal="5dp" | |||
app:layout_constraintStart_toStartOf="parent" | |||
android:layout_marginStart="8dp" app:layout_constraintEnd_toEndOf="parent" android:layout_marginEnd="8dp" | |||
android:layout_marginTop="30dp" app:layout_constraintTop_toTopOf="parent" | |||
> | |||
<ImageView | |||
android:layout_width="70dp" | |||
android:layout_height="40dp" android:id="@+id/rate_item_img_park" | |||
android:layout_weight="1" | |||
android:layout_marginRight="5dp" app:srcCompat="@drawable/magnifier" | |||
android:layout_marginVertical="5dp" | |||
android:layout_marginLeft="10dp"/> | |||
<TextView | |||
android:text="Please select a place" | |||
android:layout_width="match_parent" | |||
android:layout_height="match_parent" android:id="@+id/place_name_park" android:layout_weight="1" | |||
android:gravity="center_vertical" android:textColor="#FF616161" android:textSize="16sp" | |||
android:layout_marginLeft="7dp"/> | |||
</LinearLayout> | |||
<ImageView | |||
android:src="@drawable/app_icon" | |||
android:layout_width="329dp" | |||
android:layout_height="242dp" android:id="@+id/spot_img" | |||
android:layout_marginTop="8dp" | |||
app:layout_constraintTop_toBottomOf="@+id/search_layout_park" | |||
app:layout_constraintStart_toStartOf="@+id/search_layout_park" | |||
app:layout_constraintEnd_toEndOf="@+id/search_layout_park" android:layout_marginEnd="8dp" | |||
app:layout_constraintHorizontal_bias="0.568"/> | |||
<com.google.android.gms.maps.MapView | |||
android:layout_width="332dp" | |||
android:layout_height="205dp" | |||
android:id="@+id/spot_loc" android:layout_marginStart="8dp" app:layout_constraintStart_toStartOf="parent" | |||
android:layout_marginEnd="8dp" app:layout_constraintEnd_toEndOf="parent" android:layout_marginTop="8dp" | |||
app:layout_constraintTop_toBottomOf="@+id/spot_img" android:layout_marginBottom="8dp" | |||
app:layout_constraintBottom_toBottomOf="parent" | |||
android:apiKey="AIzaSyBuOC03IHPA_6TPnfk18b0SAgD1uge4-dk" app:layout_constraintHorizontal_bias="0.476" | |||
app:layout_constraintVertical_bias="0.274"/> | |||
</android.support.constraint.ConstraintLayout> |
@ -1,23 +1,29 @@ | |||
{ | |||
"0": { | |||
"x1": 462, | |||
"y1": 146, | |||
"x2": 686, | |||
"y2": 502, | |||
"x1": 212, | |||
"y1": 342, | |||
"x2": 378, | |||
"y2": 426, | |||
"lng": 33, | |||
"lat": 34, | |||
"priority": 0 | |||
}, | |||
"1": { | |||
"x1": 480, | |||
"y1": 504, | |||
"x2": 684, | |||
"y2": 870, | |||
"x1": 388, | |||
"y1": 344, | |||
"x2": 516, | |||
"y2": 416, | |||
"lng": 33, | |||
"lat": 34, | |||
"priority": 1 | |||
}, | |||
"2": { | |||
"x1": 484, | |||
"y1": 918, | |||
"x2": 686, | |||
"y2": 1338, | |||
"x1": 90, | |||
"y1": 338, | |||
"x2": 208, | |||
"y2": 420, | |||
"lng": 33, | |||
"lat": 34, | |||
"priority": 2 | |||
} | |||
} |
@ -1,123 +1,127 @@ | |||
{ | |||
"efe": { | |||
"id": "9vard12ty0ad2yvwp3q53rsf3h43r2vq", | |||
"realname": "Efe Aydın", | |||
"avatar": "/img/9vard12ty0ad2yvwp3q53rsf3h43r2vq.png", | |||
"password": "827ccb0eea8a706c4c34a16891f84e7b", | |||
"email": "efeaydin@mycity.com", | |||
"TC": "11111111111", | |||
"tel": "0555 555 55 55", | |||
"health": ["antibiotic allergy", "peanut allergy", "asthma"], | |||
"stats": { | |||
"bus_usage_week": 1, | |||
"bus_usage_month": 5, | |||
"bus_usage_year": 67 | |||
}, | |||
"trustability": "16", | |||
"daily_electricity_usage": [ | |||
32, | |||
34, | |||
29, | |||
28, | |||
35, | |||
31, | |||
36, | |||
38, | |||
37, | |||
40, | |||
45, | |||
47, | |||
45, | |||
47, | |||
48, | |||
44, | |||
49, | |||
53, | |||
55, | |||
49, | |||
46, | |||
42, | |||
37, | |||
34 | |||
], | |||
"daily_water_usage": [ | |||
32, | |||
34, | |||
29, | |||
28, | |||
35, | |||
31, | |||
36, | |||
38, | |||
37, | |||
40, | |||
45, | |||
47, | |||
45, | |||
47, | |||
48, | |||
44, | |||
49, | |||
53, | |||
55, | |||
49, | |||
46, | |||
42, | |||
37, | |||
34 | |||
], | |||
"ideal_electricity_usage": [ | |||
11, | |||
11, | |||
11, | |||
11, | |||
11, | |||
12, | |||
14, | |||
15, | |||
15, | |||
15, | |||
15, | |||
15, | |||
15, | |||
15, | |||
15, | |||
15, | |||
15, | |||
16, | |||
16, | |||
15, | |||
15, | |||
14, | |||
12 | |||
], | |||
"ideal_water_usage": [ | |||
11, | |||
11, | |||
11, | |||
11, | |||
11, | |||
12, | |||
14, | |||
15, | |||
15, | |||
15, | |||
15, | |||
15, | |||
15, | |||
15, | |||
15, | |||
15, | |||
15, | |||
16, | |||
16, | |||
15, | |||
15, | |||
14, | |||
12 | |||
], | |||
"points": 50, | |||
"electricity_bill": 100, | |||
"water_bill": 120 | |||
} | |||
} | |||
"efe": { | |||
"id": "9vard12ty0ad2yvwp3q53rsf3h43r2vq", | |||
"realname": "Efe Ayd\u0131n", | |||
"avatar": "/img/9vard12ty0ad2yvwp3q53rsf3h43r2vq.png", | |||
"password": "827ccb0eea8a706c4c34a16891f84e7b", | |||
"email": "efeaydin@mycity.com", | |||
"TC": "11111111111", | |||
"tel": "0555 555 55 55", | |||
"health": [ | |||
"antibiotic allergy", | |||
"peanut allergy", | |||
"asthma" | |||
], | |||
"stats": { | |||
"bus_usage_week": 1, | |||
"bus_usage_month": 5, | |||
"bus_usage_year": 67 | |||
}, | |||
"trustability": "16", | |||
"daily_electricity_usage": [ | |||
32, | |||
34, | |||
29, | |||
28, | |||
35, | |||
31, | |||
36, | |||
38, | |||
37, | |||
40, | |||
45, | |||
47, | |||
45, | |||
47, | |||
48, | |||
44, | |||
49, | |||
53, | |||
55, | |||
49, | |||
46, | |||
42, | |||
37, | |||
34 | |||
], | |||
"daily_water_usage": [ | |||
32, | |||
34, | |||
29, | |||
28, | |||
35, | |||
31, | |||
36, | |||
38, | |||
37, | |||
40, | |||
45, | |||
47, | |||
45, | |||
47, | |||
48, | |||
44, | |||
49, | |||
53, | |||
55, | |||
49, | |||
46, | |||
42, | |||
37, | |||
34 | |||
], | |||
"ideal_electricity_usage": [ | |||
11, | |||
11, | |||
11, | |||
11, | |||
11, | |||
12, | |||
14, | |||
15, | |||
15, | |||
15, | |||
15, | |||
15, | |||
15, | |||
15, | |||
15, | |||
15, | |||
15, | |||
16, | |||
16, | |||
15, | |||
15, | |||
14, | |||
12 | |||
], | |||
"ideal_water_usage": [ | |||
11, | |||
11, | |||
11, | |||
11, | |||
11, | |||
12, | |||
14, | |||
15, | |||
15, | |||
15, | |||
15, | |||
15, | |||
15, | |||
15, | |||
15, | |||
15, | |||
15, | |||
16, | |||
16, | |||
15, | |||
15, | |||
14, | |||
12 | |||
], | |||
"points": 45, | |||
"electricity_bill": 100, | |||
"water_bill": 120 | |||
} | |||
} |
@ -1,119 +0,0 @@ | |||
import cv2 | |||
import numpy as np | |||
import json | |||
from matplotlib import pyplot as plt | |||
import cv2 | |||
import numpy as np | |||
import json | |||
import os | |||
from matplotlib import pyplot as plt | |||
import xml.etree.ElementTree as ET | |||
import cv2 | |||
import numpy as np | |||
import os | |||
import json | |||
from pysolar.solar import * | |||
from datetime import datetime | |||
def calcAvg(img,locations_xml): | |||
locations_extracted = [] | |||
loc_images = {} | |||
average_values = {} | |||
for i in range( len( locations_xml ) ): | |||
try: | |||
locations_extracted.append([]) | |||
for j in range(4): | |||
locations_extracted[i].append(locations_xml[i][1][j].attrib) | |||
locations_extracted[i].append(locations_xml[i].attrib['occupied']) | |||
locations_extracted[i].append(locations_xml[i].attrib['id']) | |||
except Exception: | |||
print("xml corrupt!") | |||
return {} | |||
for col in range(len(img)): | |||
for pix in range(len(img[col])): | |||
if (img[col][pix] == [255,255,255]).all(): | |||
img[col][pix] == [255,255,254] | |||
for i in range(len(locations_extracted)): | |||
temp = locations_extracted[i] | |||
pts = np.array([[int(temp[0]['x']),int(temp[0]['y'])], | |||
[int(temp[1]['x']),int(temp[1]['y'])], | |||
[int(temp[2]['x']),int(temp[2]['y'])], | |||
[int(temp[3]['x']),int(temp[3]['y'])]]) | |||
rect = cv2.boundingRect(pts) | |||
x,y,w,h = rect | |||
croped = img[y:y+h, x:x+w].copy() | |||
pts = pts - pts.min(axis=0) | |||
mask = np.zeros(croped.shape[:2], np.uint8) | |||
cv2.drawContours(mask, [pts], -1, (255, 255, 255), -1, cv2.LINE_AA) | |||
dst = cv2.bitwise_and(croped, croped, mask=mask) | |||
bg = np.ones_like(croped, np.uint8)*255 | |||
cv2.bitwise_not(bg,bg, mask=mask) | |||
dst2 = bg+ dst | |||
blurred = cv2.GaussianBlur(dst2,(5,5),3) | |||
edges = cv2.Canny(blurred,100,100) | |||
if not temp[4] in loc_images: | |||
loc_images[temp[4]] = {} | |||
loc_images[temp[4]][temp[5]] = edges | |||
for state in loc_images: | |||
average_values[state] = {} | |||
for lot in loc_images[state]: | |||
reps = 0 | |||
for col in loc_images[state][lot]: | |||
for pix in col: | |||
if(pix == 255): | |||
reps += 1 | |||
average_values[state][lot] = reps | |||
print (average_values) | |||
return average_values | |||
def generateAvg(): | |||
dates = os.listdir('./PKLot/PKLot/PUCPR/Sunny') | |||
imgs = [] | |||
averages={} | |||
back_file = open("backup.json","w") | |||
back_file.write("{") | |||
for i in range(len(dates)): | |||
imgs.append(os.listdir(os.path.join('./PKLot/PKLot/PUCPR/Sunny',dates[i]))) | |||
for i in range(len(imgs)): | |||
for j in range(len(imgs[i])): | |||
if(imgs[i][j][-4:] == ".jpg"): | |||
try: | |||
img_location = os.path.join('./PKLot/PKLot/PUCPR/Sunny',dates[i],imgs[i][j]) | |||
locs = ET.parse(img_location[:-4] + ".xml").getroot() | |||
print(img_location,end=" ") | |||
average = calcAvg(cv2.imread(img_location),locs) | |||
if not(average == {}): | |||
averages[img_location] = average | |||
back_file.write("'"+img_location + "':" + str(average)) | |||
except Exception: | |||
continue | |||
back_file.write("}") | |||
js = json.dumps(averages) | |||
print(js) | |||
fp = open('data.json', 'w') | |||
fp.write(js) | |||
fp.close() | |||
generateAvg() | |||
@ -1,28 +0,0 @@ | |||
import os | |||
import copy | |||
import json | |||
from flask import Flask, request | |||
from flask_restful import Resource, Api, abort | |||
app = Flask(__name__) | |||
api = Api(app) | |||
class Empty(Resource): | |||
def get(self): | |||
try: | |||
rating = copy.deepcopy(ratings[rating_id - 1]) | |||
del rating['rates'] | |||
return rating | |||
except: | |||
abort(404, error="Rating {} doesn't exist".format(rating_id)) | |||