#Launch an instance http://docs.aws.amazon.com/AmazonVPC/latest/GettingStartedGuide/GetStarted.html
#Setup EC2
chmod 400 key.pem
ssh -i key.pem ec2-user@YOUR_SERVER_IP
import React from 'react' | |
import ReactDOM from 'react-dom' | |
import axios from 'axios' | |
class App extends React.Component { | |
constructor(props) { | |
super(props) | |
this.state = { | |
cosmic: null, | |
loading: true | |
} |
import React, { Component } from 'react'; | |
import './App.css'; | |
class App extends Component { | |
render() { | |
return ( | |
<div className="App"> | |
<img style={{ width: '100%' }} src="https://thecatapi.com/api/images/get?format=src&type=jpg"/> | |
</div> | |
); |
const gql_query = `{ | |
objects(bucket_slug: "${config.bucket.slug}") { | |
type_slug | |
slug | |
title | |
content | |
metadata | |
created_at | |
} | |
}` |
import axios from 'axios' | |
import _ from 'lodash' | |
import Footer from './partials/footer' | |
import Header from './partials/header' | |
import helpers from '../helpers' | |
import config from '../config' | |
export default class extends React.Component { | |
static async getInitialProps({ req }) { | |
const query = `{ |
{ | |
"scripts": { | |
"dev": "node server.js", | |
"build": "next build", | |
"start": "next build; NODE_ENV=production node server.js" | |
}, | |
"dependencies": { | |
"axios": "^0.16.2", | |
"express": "^4.16.2", | |
"lodash": "^4.17.4", |
import React from 'react' | |
import Cosmic from 'cosmicjs' | |
const config = { | |
bucket: { | |
slug: 'next-app' | |
} | |
} | |
export default class extends React.Component { | |
static async getInitialProps({ req }) { | |
return new Promise((resolve, reject) => { |
#Launch an instance http://docs.aws.amazon.com/AmazonVPC/latest/GettingStartedGuide/GetStarted.html
#Setup EC2
chmod 400 key.pem
ssh -i key.pem ec2-user@YOUR_SERVER_IP
<?php | |
class Curl { | |
public function get($url){ | |
$ch = curl_init($url); | |
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET"); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | |
$result = curl_exec($ch); |
<?php | |
function getBetween($content,$start,$end){ | |
$r = explode($start, $content); | |
if (isset($r[1])){ | |
$r = explode($end, $r[1]); | |
return $r[0]; | |
} | |
return ''; | |
} | |
?> |