File tree 5 files changed +26
-8
lines changed
appengine-simple-jetty-main/src/main/java/com/example/appengine/demo/jettymain
http-server/src/main/java/com/example/appengine
sparkjava-helloworld/src/main/java/com/example/appengine/sparkdemo 5 files changed +26
-8
lines changed Original file line number Diff line number Diff line change @@ -32,11 +32,13 @@ public static void main(String[] args) throws Exception {
32
32
System .setProperty ("org.eclipse.jetty.util.log.class" , "org.eclipse.jetty.util.log.StrErrLog" );
33
33
System .setProperty ("org.eclipse.jetty.LEVEL" , "INFO" );
34
34
35
- // Create a basic Jetty server object that will listen on port 8080.
35
+ // Create a basic Jetty server object that will listen on port defined by
36
+ // the PORT environment variable when present, otherwise on 8080.
36
37
// Note: If you set this to port 0, a randomly available port will be
37
38
// assigned. You can find the assigned port in the logs or programmatically
38
39
// obtain it.
39
- Server server = new Server (8080 );
40
+ int port = Integer .parseInt (System .getenv ().getOrDefault ("PORT" , "8080" ));
41
+ Server server = new Server (port );
40
42
41
43
// The WebAppContext is the interface to provide configuration for a web
42
44
// application. In this example, the context path is being set to "/" so
Original file line number Diff line number Diff line change 23
23
public class Main {
24
24
25
25
public static void main (String [] args ) throws IOException {
26
- // Create an instance of HttpServer bound to port 8080.
27
- HttpServer server = HttpServer .create (new InetSocketAddress (8080 ), 0 );
26
+ // Create an instance of HttpServer bound to port defined by the
27
+ // PORT environment variable when present, otherwise on 8080.
28
+ int port = Integer .parseInt (System .getenv ().getOrDefault ("PORT" , "8080" ));
29
+ HttpServer server = HttpServer .create (new InetSocketAddress (port ), 0 );
28
30
29
31
// Set root URI path.
30
32
server .createContext ("/" , (var t ) -> {
Original file line number Diff line number Diff line change 24
24
public class Main {
25
25
26
26
public static void main (String [] args ) throws IOException {
27
- // Create an instance of HttpServer with port 8080.
28
- HttpServer server = HttpServer .create (new InetSocketAddress (8080 ), 0 );
27
+ // Create an instance of HttpServer bound to port defined by the
28
+ // PORT environment variable when present, otherwise on 8080.
29
+ int port = Integer .parseInt (System .getenv ().getOrDefault ("PORT" , "8080" ));
30
+ HttpServer server = HttpServer .create (new InetSocketAddress (port ), 0 );
29
31
30
32
// Set root URI path.
31
33
server .createContext ("/" , (var t ) -> {
Original file line number Diff line number Diff line change 21
21
public class Main {
22
22
23
23
public static void main (String [] args ) {
24
- // Starts the webapp on localhost:8080.
25
- Spark .port (8080 );
24
+ // Starts the webapp on localhost and the port defined by the PORT
25
+ // environment variable when present, otherwise on 8080.
26
+ int port = Integer .parseInt (System .getenv ().getOrDefault ("PORT" , "8080" ));
27
+ Spark .port (port );
26
28
Spark .get ("/" , (req , res ) -> "Hello World!" );
27
29
}
28
30
}
Original file line number Diff line number Diff line change @@ -14,6 +14,16 @@ using the [Google Cloud Client Library for Java][google-cloud-java].
14
14
15
15
## Setup
16
16
17
+ Before you begin, complete the following steps as listed on the [ Speech-to-Text Docs pages for Getting Started] ( https://cloud.google.com/speech-to-text/docs/quickstart-client-libraries#before-you-begin )
18
+ * Create or select a project.
19
+ * Enable the Google Speech-to-Text API for that project.
20
+ * Create a service account.
21
+ * Download a private key as JSON.
22
+ * Set ` GOOGLE_APPLICATION_CREDENTIALS `
23
+ ```
24
+ export GOOGLE_APPLICATION_CREDENTIALS=path_to_your_downloaded_json_file
25
+ ```
26
+
17
27
Install [ Maven] ( http://maven.apache.org/ ) .
18
28
19
29
Build your project with:
You can’t perform that action at this time.
0 commit comments