|
Java example source code file (ApiResource.java)
The ApiResource.java Java example source code/* * * * Copyright 2015 Skymind,Inc. * * * * Licensed under the Apache License, Version 2.0 (the "License"); * * you may not use this file except in compliance with the License. * * You may obtain a copy of the License at * * * * http://www.apache.org/licenses/LICENSE-2.0 * * * * Unless required by applicable law or agreed to in writing, software * * distributed under the License is distributed on an "AS IS" BASIS, * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * * See the License for the specific language governing permissions and * * limitations under the License. * */ package org.deeplearning4j.ui.api; import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider; import org.apache.commons.io.FileUtils; import org.apache.commons.math3.stat.descriptive.rank.Percentile; import org.deeplearning4j.ui.providers.ObjectMapperProvider; import org.deeplearning4j.ui.storage.SessionStorage; import org.deeplearning4j.ui.storage.def.ObjectType; import org.deeplearning4j.ui.uploads.FileResource; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.ws.rs.*; import javax.ws.rs.client.Client; import javax.ws.rs.client.ClientBuilder; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import java.io.File; import java.io.IOException; import java.util.ArrayList; import java.util.List; /** * This class handles T-SNE coords upload (in tsv format), and provides output to the browser via JSON * * @author Adam Gibson */ @Path("/api") @Produces(MediaType.APPLICATION_JSON) public class ApiResource extends FileResource { // TODO: this list should be replaced with HistoryStorage private static final Logger logger = LoggerFactory.getLogger(FileResource.class); private List<String> coords; private Client client = ClientBuilder.newClient().register(JacksonJsonProvider.class).register(new ObjectMapperProvider()); private volatile SessionStorage storage = SessionStorage.getInstance(); /** * The file path for uploads * * @param filePath the file path for uploads */ public ApiResource(String filePath) { super(filePath); } /** * The file path for uploads * */ public ApiResource() { this("."); } @POST @Path("/update") @Produces(MediaType.APPLICATION_JSON) public Response update() throws IOException { //String content = client.target(resource.getUrl()).request(MediaType.TEXT_PLAIN_TYPE).get(String.class); //List<String> testLines = IOUtils.readLines(new ByteArrayInputStream(content.getBytes())); //HistoryStorage.getInstance().put("TSNE", Pair.makePair(1, 0), testLines); List<String> testLines = (List Other Java examples (source code examples)Here is a short list of links related to this Java ApiResource.java source code file: |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.